Question

i m trying to implement this thing , that when ever a person opens up a page an automatic request goes to some server . i m doing this with ajax by calling a function on onload event of body .. but it is giving me Access Restricted to URI 1012 error .. then i used jquery .. and used its post() method .. now it is giving me 403 Forbidden error .. what should i do ?

"http://www.somedomain.com/WebSite1/Default2.aspx" this is the link i am accessing but it is giving me 403 Forbidden .

function doIt(_id){

$(document).ready(function() {
          var a = Math.floor(Math.random()*22222);
       var b = Math.floor(Math.random()*66666);
    $.post('http://www.somedomain.com/WebSite1/Default2.aspx?id='+_id,{'uname': a , 'upass' : b },function(data){
            //alert(data);
   });
 });
}

this is my code that i am calling

Was it helpful?

Solution

You cannot do a xhr (ajax) request to another domain. Browsers implement a same domain policy. Your three choices are to use a jsonp call, use a server side proxy your side to make the request or use an iFrame to make the request.

OTHER TIPS

You are attempting "cross-site scripting", that is you are accessing a different site than the one that served up the javascript in the first place. This is usually forbidden by the browser for (good) security reasons.

If your server can see the other site then you can create a proxy service. In doing so you are taking some responsibility for the content so served.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top