Select to view content in your preferred language

Error: xhr cancelled in IE8 using esri.request

813
1
12-12-2012 10:27 AM
ReneRubalcava
Honored Contributor
Oddly enough, I just saw this thread right now and found I am having the same error with something I am working on right now, but a different scenario, so I made a new thread.

This only happens in IE8, which is what I need to support in my office. It works fine in Chrome and FF, so I'm not sure what the problem is.

I am using esri.request to submit parameters to a non-arcgis web service. However, in IE8 it is appending the parameters the application pages URL and refreshing the page when I send the request.

I am using a dijit/form to collect and submit data on a (non-submit) dijit.form.button. I can tell it's not the form submitting because I can see my console debugs before the request happens.

Here is the onClick event handler for my form.

_onFlowTraceClick: function(e) {
 e.preventDefault();
 e.stopPropagation();

 var form = registry.byId('flowTraceForm');
 var data = form.getValues();
 console.log('values?', data);
 var _this = this;

 var url = '/csdapi/api/flow/trace';
 var params = {
  id: data.name,
  direction: data.direction,
  districts: data.nodetype === 'districts'
 };

 var len = data.status.length; // an array of checkboxes
 while(len--) {
  params[data.status[len]] = true;
 }

 console.log('params for trace', params); // I see all debug consoles up to here

 var request = esri.request({
  url: url,
  content: params
   });

 request.then(function(response, io) {

  console.log('got a response!', response, io);
  response.bubble = true;
  response.cancelable = true;
  _this.emit('flowTraceResults', response);

 });

}


When it reaches the esri.request() line it appends the parameters to the pages URL, so my app can be http://testgis/demo
and it turns into http://testgis/demo?id=999&nodetype=local&direction=up and my page refreshes. It's just weird.

*edit, it looks like it might be the form.getValues() causing an issue, because the params it adds to my URL match the form and not the custom params I make.

I do have a proxy.ashx set up with mustMatch=false for dev purposes and I can see it working in Chrome and FF.

Has anyone else seen this happen before?
0 Kudos
1 Reply
ReneRubalcava
Honored Contributor
Ok, got it.
My widget template had the following as the html template for my button.
<button data-dojo-type="dijit.form.Button" data-dojo-attach-point="buttonWidget"
                  data-dojo-attach-event="onClick:_onFlowTraceClick">Trace</button>


I have to add button="type" to that or it defaults to a type of submit, which only seems to affect IE at least version 8.

I guess I just needed to write it down to work it out. Maybe this will help someone else that comes across this problem.
0 Kudos