i have following ajax call:
$.ajax({ type: "post", url: urltogetrules, data: { rulename: rulename}, }) .success(function (data) { document.location.href = "/studentrules/getallstudentrules?productid=test"; }) .fail(function (xhr) { alert("something went wrong!!!") console.log(xhr.responsetext); });
in controller creating document in docdb so:
[httppost] public actionresult upsertdoc(string rulename) { studentrule studentrule = new studentrule() { id = guid.newguid().tostring(), studentid = "test", name = rulename, ruletype = "allow updates", startdate = datetime.utcnow.tostring() }; _updateschedulerulesmanager.upsertschedulerule(studentrule); return json(new { success = true }); }
the idea return page list rules once user creates new rule in add rule page.
the above code executes fine , can see expected document in docdb status call in developer tools shows 'pending'!!! code in success never executes.
can please guide me here?
thanks in advance.
there no .success
handler.
deprecation notice: jqxhr.success(), jqxhr.error(), , jqxhr.complete() callbacks deprecated of jquery 1.8. prepare code eventual removal, use jqxhr.done(), jqxhr.fail(), , jqxhr.always() instead.
you need use done:
$.ajax({ type: "post", url: '@url.action("upsertdoc")', data: { rulename: 'test'}, }).done(function (data) { document.location.href = "/studentrules/getallstudentrules?productid=test"; }).fail(function (xhr) { alert("something went wrong!!!") console.log(xhr.responsetext); });
also remove spacing before .done
, .fail
.
screen shot
Comments
Post a Comment