I am new about Arcgis javascript API. While I am doing a sample application, I confused. I am analyzing this sample application.

This application is using the http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Louisville/LOJIC_LandRecords_Louisville/MapServer/0 as FeatureLayer.

And using a proxy

    esri.config.defaults.io.proxyUrl = "/proxy";
    esri.config.defaults.io.alwaysUseProxy = false;

I created a new visual studio project and proxy pages. And I changed FeatureLayer and Base Map. Program is working. But I opened Mozilla Firebug and traced the traffic. My Application using multiple Http POST data, while zoom in. But Arcgis application Only 2 GET

This is my custom application screencast. (This is screenCast of my application https://i.sstatic.net/F1C17.png)

This is Arcgis Sample Application here

This is Arcsgis Application screencast:



1 Answer 1


When you are sending a geometry to query a feature service, say for an intersection, the geometry is going to be large for a polygon. It will usually exceed the 2000 character limit for a get request. When it exceeds that limit, esri.request will send a post request, which requires the proxy, if you haven't specified that the server is CORS enabled.

However, I've noticed that sometimes adding a CORS server doesn't always work. (esri.config.defaults.io.corsEnabledServers.push("sampleserver1.arcgisonline.com");) It's safest to add to CORS and also have proxy...and let esri.request figure it out. It's better performance if the esri.request uses CORS.

Also to clarify, esri.request is being used by API calls like query a feature service.

http://help.arcgis.com/en/webapi/javascript/arcgis/jshelp/inside_esri_request.html Check out this help topic and in particular

Under the Hood: Determining Which Dojo Method is Used
esri.request uses the appropriate method to execute a request based on the target of the request and what the browser supports. The native method to do AJAX requests is to use XMLHttpRequest(XHR). Because there are subtle differences in how XHR is implemented across browsers, Dojo abstracts away and addresses cross-browser inconsistencies via dojo.xhrGet and dojo.xhrPost. Dojo also provides methods in the dojo.io namespace to do AJAX-style requests with JSONP and to use an iframe to upload files. esri.request sits on top of the methods defined by Dojo to provide a clean, simple way to execute AJAX-style requests. Depending on the arguments passed to esri.request, different Dojo methods are used. The following pseudocode is a rough outline of how esri.request works.

If JSONP request
  If target on same domain
    Convert to JSON request
  Else If CORS available
    Convert to JSON request
    If request size is 2000 characters or less
      Call dojo.io.script.get
      Convert to JSON request

JSON / XML / plain text:
If JSON / XML / PlainText request
  If target not on same domain && CORS not available
    Rewrite request url to use proxy
  If request size is 2000 characters or less
    Call dojo.xhrGet
    Call dojo.xhrPost

http://help.arcgis.com/en/webapi/javascript/arcgis/jshelp/inside_defaults.html esri.config.defaults.io.corsEnabledServers
Add URLs for servers with cross-origin resource sharing enabled to this array. Cross-Origin Resource Sharing (CORS) allows web applications to bypass the browser's same origin policy file and access resources or services on different servers/domains. When both the web server and browser support CORS, esri.request will not use a proxy to perform cross-domain requests. The API includes some Esri servers by default so it's important to push items on to this array rather than overwriting it.

function pageReady(){
At version 2.8, the list contains the following servers by default:
At version 3.1 the following domains were added to the list:
  • An important point of your answer is 2000 character limit for a get request. I understand that. When I open this[help.arcgis.com/en/webapi/javascript/arcgis/samples/… application in firebug, sending only One GET request to sampleserver1.arcgisonline.com. So T think the arcgis server rest service sending data less than 2000. But there are tons of lines on the map. My arcgis rest service gets lines but sending POST rewuest.
    – barteloma
    Commented May 30, 2013 at 6:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.