backbone.service icon indicating copy to clipboard operation
backbone.service copied to clipboard

Data not being posted

Open kmaiorini82 opened this issue 8 years ago • 2 comments

For some reason I am not sending/posting any data. Believe I am using it correctly. Don't really see that much different but have to be doing something wrong! Code, entire index.html, below...

Test
<!-- Bootstrap -->
<link href="assets/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">

<!-- Custom CSS -->
<link href="assets/css/global.css" rel="stylesheet">

<!-- Prevent favicon error -->
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
<div class="container">

</div>

<script src="js/external/jquery-2.2.0.min.js"></script>
<script src="js/external/underscore-min.js"></script>
<script src="js/external/backbone-min.js"></script>
<script src="js/external/backbone.service.min.js"></script>
<script>
    // define server targets/endpoints
    var targets = {
      login: ["/auth.php", "post"],
    };

    // standalone service
    var service = new Backbone.Service({ url: "https://localhost:4431", targets: targets });

    // extend backbone model
    var User = Backbone.Model.extend(service);

    var myUser = new User();
    myUser.login({ employee_id: 'test', password: 'test', group: 'test' }, {
        success: function (res) {
            console.log(JSON.stringify(res));
            console.log("Success: " + res.response_text);
        },
        error: function (res) {
            console.log("Error: " + res);
        }
    });

</script>

The entry in my access logs is simply...

172.19.59.6 - - [18/Feb/2016:08:20:33 -0500] "POST /auth.php...

It should be...

172.19.59.6 - - [18/Feb/2016:08:13:52 -0500] "POST /auth.php?employee_id=test&password=t&group=test...

kmaiorini82 avatar Feb 18 '16 13:02 kmaiorini82

Any update on this? Really at a loss on what is going on. I tried modifying my web service to ensure that it can handle json encoded data, which it does. I tried everything/anything I could find and no luck.

Please advise.

kmaiorini82 avatar Feb 23 '16 17:02 kmaiorini82

@kmaiorini82 sorry for not getting back to you sooner. It looks like you defined a POST request in your target but you are expecting to the lib to create a GET request? I added a working example based on your code here: https://github.com/mkuklis/backbone.service/blob/master/examples/index.html

Please let me know if this helps.

mkuklis avatar Mar 01 '16 11:03 mkuklis