Hi those who were working in Ajax, will surely experienced with this problem. SOP - Single Origin Policy problem. I am doing a small work in Prototype Ajax. I did a sample work. When I am passing the URL to the Ajax call within the same directory. It is showing an exception "Access Denied". The cause for this exception is SOP. This occur only with the IE. Had anyone overcome this problem. If so means pls tell me that would be very helpful for me.
The sample code I worked out
[HTML]<html>
<head>
<title>Prototype GET Example</title>
<script type="text/javascript"src="prototype.js"></script>
<script type="text/javascript">
function requestCustomerInfo() {
var sId = document.getElementById("txtCustomerId").value;
var oOptions = {
method: "get",
onSuccess: function (oXHR, oJson) {
displayCustomerInfo(oXHR.responseText);
},
onFailure: function (oXHR, oJson) {
displayCustomerInfo("An error occurred: " +
oXHR.statusText);
},
onException: function (oXHR, oJson) {
displayCustomerInfo("An Exception occurred: " +
oXHR.statusText);
}
};
var oRequest = new Ajax.Request("demo1.html", oOptions);
}
function displayCustomerInfo(sText) {
var divCustomerInfo = document.getElementById("divCustomerInfo");
divCustomerInfo.innerHTML = sText;
}
</script>
</head>
<body>
<p>Enter customer ID number to retrieve information:</p>
<p>Customer ID: <input type="text" id="txtCustomerId" value="" /></p>
<p><input type="button" value="Get Customer Info" onclick="requestCustomerInfo()" /></p>
<div id="divCustomerInfo"></div>
</body>
</html>[/HTML]
This piece of code is working fine with all the other browser except the IE. If u wantto test this file, pls download the prototype.js from the site http://prototypejs.org/download and have the demo1.html file within the same folder. Then only u will be able to view the change. I am not using any server kind of stuff. Any one having solution to the SOP problem pls help me out
Regards
Ramanan Kalirajan