Note that there are some explanatory texts on larger screens.

plurals
  1. POBackbone model save triggers error callback on Chrome/FF
    primarykey
    data
    text
    <p>Noob question here:</p> <p>I'm using ASP.NET MVC 3 and I'm trying to save an entity through Backbone. Here's what I have:</p> <p>I defined my Backbone model (Program) as such:</p> <pre><code>var Program = Backbone.Model.extend({ defaults: function () { return { name: "" }; }, initialize: function (attrs) { this.set('name', attrs.name); }, urlRoot: '/program/add' }); </code></pre> <p>Then I hook up the model save on the click event of a button:</p> <pre><code>$('.add-program').click(function () { var programName = $('.program-name').val(); var program = new Program({ name: programName }); program.save(null, { success: function (model, response) { alert('success'); }, error: function (model, response) { alert('error'); } }); }); </code></pre> <p>It works on IE (surprisingly!) - ProgramController.Add(string name) gets called fine and I get a success response. But <strong>I'm having issues on Chrome and FF - They both trigger the error callback</strong> with the slight difference that on Chrome my Controller Action doesn't even get hit at all (it does on FF though). The funny thing is that my action breakpoint does get hit on FF, with the appropriate param value, but still get the error callback. </p> <p>I'm not sure what's going on here. I tried debugging through Firebug/Chromebug and don't see much on the error callback params (the errorStatus is just ... well... "error"!). I also tried looking at the Network tab and Fiddler and I don't see anything that rings a bell (maybe I'm not looking at the right place). I also tried doing a straight jquery ajax call to the controller and still get the same weird behavior. </p> <p>Just in case, here's the MVC action (although I don't think the issue is here):</p> <pre><code>[HttpPost] public JsonResult Add(string name) { var stubbedResponse = new {id = Guid.NewGuid()}; return Json(stubbedResponse); } </code></pre> <p>Any ideas what could be causing this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload