Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
Hello,

I am making a cross origin ajax HTTP request from 'http://localhost:8080/[some string value].html' to a remote server machine.Actually this request is made to get a list of HDFS file system information which is installed in the remote server. Request URL is:
 
var formURL =  http://[remote server name]:[port number]/**webhdfs**/v1/xd/?op=LISTSTATUS. 

 and the ajax call is like:
 $.ajax({
		url: formUrl,
		dataType: 'json',
		success: function(response)
 		{
            alert("Response is: "+response);
        }
});

response is expected a json array like below

{"FileStatuses":{"FileStatus":[
{"accessTime":1449652575549,"blockSize":134217728}]}}

While I am getting this response in IE 10, but for all other browsers it's  throwing a browser level error as:

"XMLHttpRequest cannot load http://[remote server name]:[port number]/**webhdfs**/v1/?op=LISTSTATUS. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access."

I searched google, its solution is to write java servlet method to set response header as "Access-Control-Allow-Origin, http://localhost:8080".

As this ajax request is not meant for any server side java method as ajax request generally does, how can I get rid this issue? 
Posted

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900