AnsweredAssumed Answered

esri.request method not returning deferred object

Question asked by zconlen on Jun 6, 2013
Latest reply on Jun 10, 2013 by zconlen
Hi,
I'm using esri.request method to do adds, deletes, edits to a feature service in my app. And to add attachments. The behavior I'm experiencing is that the callback functions I am defining are fired immediately instead of waiting for the request to complete. The callback function for successful requests is supposed to refresh the map service, which it does, but too soon, and thus does not display the new data. Also, the function for failed requests gets fired even on successful requests.

Here is an example section of code:
function delIncident() {   var feature = map.infoWindow.getSelectedFeature();    var incidentID = feature.attributes.incidentID;   var url = esri.urlToObject("http://.../FeatureServer/1/applyEdits?deletes=" + String(incidentID) + "&f=json");   var requestHandle = esri.request({      url: url.path,     content: url.query       }, {useProxy:true, usePost:true});      requestHandle.then(reqSucceeded('delIncident'),       reqFailed('delIncident')     ); }


I can make this work by using the javascript setTimeout method (to have the callback methods called only after a short delay), but I believe I should not have to do this.

The weird part is that this was all working as expected at one point. Perhaps something I changed in another part of the code caused this but I can't find it if so.

Using AGS 10.0 and jsapi 2.8.

Anyone have an idea what's wrong here?

Thanks.

Outcomes