json - How to prevent cancellation of ajax request upon redirect? -
this first ajax request. don't want client browser wait, code not waiting success. redirects page immediately. it's not working.
$.ajax({ data: '{}', url: "service.asmx/getnextid", success: function(msg1) { $.ajax({ type: "post", cache: false, contenttype: "application/json; charset=utf-8", datatype: "json", timeout: 5000, url: "service.asmx/savedata", datafilter: function(data) {var msg = (typeof (json) !== 'undefined' && typeof (json.parse) === 'function') ? json.parse(data) : eval('(' + data + ')');return (msg.hasownproperty('d')) ? msg.d : msg;}, data: "{id:'" + $get('<%=txt1.clientid %>').value + "',date:'<%=cutoffdate%>',data:'" + $("#<%=txt2.clientid %>").val() + "'}", error: function(xhr, desc, exception){ alert("failed!"); } }); window.location = "../result.aspx?id=" + msg1.id; }, error: function(xhr, desc, exception) { } });
so since it's not waiting success , redirects page, next call "savadata" getting cancelled.
is there workaround?
wait few secs before redirecting ?
Comments
Post a Comment