ajax - Backbone.js model fetch: parameters cause success/error/completed callbacks not to trigger -


if put parameters in, no success/error/completed callbacks, fiddler shows 200 response , requested json data there. that's key. fiddler showing round trip success , requested data here client side , in order. problem backbone success/failure/completed not called. big nothing.

with exact same base url, if take parameters out (and remove them web service in parallel), both success , completed triggered. below fetch "with" parameters:

mymodel.fetch({     data: {         name: 'bob',         userid: '1',         usertype: 'new'     } }, {     success: (function () {         alert(' service request success: ');     }),     error: (function (e) {         alert(' service request failure: ' + e);     }),     complete: (function (e) {         alert(' service request completed ');     }) }); 

how can backbone behavior different? it's same url, or without parameters.

i'm guessing distinction under hood in backbone fetch, "with" parameters scenario post , "without" parameters simple get. ie console reflects different output.

"with" parameters ie browser console reports warning (not error warning) request required cors:

!sec7118: xmlhttprequest http://example.com/service/myservice.asmx/myoperation?name=bob&userid=1&usertype=new required cross origin resource sharing (cors).

i think it's telling me "hey, made cross origin request , let through". "without" parameters don't warning. have service headers set to:

access-control-allow-origin: *

and responses indeed come reflecting policy.

so question why don't backbone success/error/completed callbacks trigger "with" parameters? data makes back. shouldn't backbone reflect success?

put success, error, , complete methods in same object have data. there should single object. under hood backbone uses jquery's ajax() method object pass fetch() can use property included in settings object passed $.ajax().

mymodel.fetch({     data: {         name: 'bob',         userid: '1',         usertype: 'new'     },     success: (function () {         alert(' service request success: ');     }),     error: (function (e) {         alert(' service request failure: ' + e);     }),     complete: (function (e) {         alert(' service request completed ');     }) }); 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -