I used ajax to write a WebGIS of ArcIMS. During the test, the data of other cities on the network was linked. Of course, the cross-origin problem is inevitable. The essence of Ajax cross-origin is JavaScript.ProgramOnly allow access to the data in the domain, while cross-domain access is restricted. A warning is displayed in IE, And it is terminated directly in ff, therefore, my WebGIS cannot be used in FF before cross-domain resolution (if the data is still available in the local domain ).
Now, the cross-origin solution is simple, that is, you can create a program in this domain that does not use the xhr object to send requests and receive responses. Therefore, ASP, ASPnet, JSP, or servlet can all take on this responsibility. The following is an ASPnet proxy I wrote:
Using system; using system. data; using system. text; using system. io; using system. configuration; using system. web; using system. web. security; using system. web. ui; using system. net; public partial class Proxy: system. web. UI. page {protected void page_load (Object sender, eventargs e) {string url = request ["url"]. tostring (); string clientversion = request ["clientversion"]. tostring (); string customservice = ST Ring. Empty; string url = string. Empty; If (request ["customservice"]! = NULL) // note that the form parameter {customservice = request ["customservice"] is not required. tostring (); url = URL + "& customservice =" + customservice + "& clientversion =" + clientversion;} else {url = URL + "& clientversion =" + clientversion ;} string ArcXML = request ["ArcXML"]. tostring (); byte [] postbytes = encoding. utf8.getbytes (ArcXML); string result = string. empty; httpwebrequest httpwreq = (httpwebrequest) webrequest. create (URL); httpwreq. method = "Post"; httpwreq. contenttype = "application/X-WWW-form-urlencoded"; httpwreq. contentlength = postbytes. length; using (Stream reqstream = httpwreq. getrequeststream () {reqstream. write (postbytes, 0, postbytes. length);} httpwebresponse httpwresp = (httpwebresponse) httpwreq. getresponse (); streamreader reader = new streamreader (httpwresp. getresponsestream (), encoding. utf8); Result = reader. readtoend (); // httpwresp. close (); response. write (result); response. end ();}}