Search code examples
jqueryajaxaccess-deniedhttp-status-code-403

Automatic Request to a web Page


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


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.