English 中文(简体)
jquery ajax 正在从其他领域得到回复
原标题:jquery ajax getting response from url of other domains
  • 时间:2012-01-13 04:04:52
  •  标签:
  • ajax
  • jquery

I have tried the following code, but the AJAX call does not get a response. Please tell me why I am getting a failed AJAX call.

   $.ajax({
    type: "GET",
    dataType:"html",
    url: "http://www.example.com",
            //url = any url other than the same domain
    success: function(response,status){
        alert(status);
        //$("#search_text").val("");
        //$("#search_results").html(msg);
        //setTimeout( refresh() ,2000);

        //alert($("#sw_hdr"));

    }
});
最佳回答

You can t use AJAX to communicate across domains. Well, you can but jQuery s Ajax function won t do it. Look up XSS attacks for more information

http://en.wikipedia.org/wiki/Cross-site_scripting”rel=“nofollow”http://en.wikipedia.org/wiki/Cross-site_scripting

问题回答

You can still use JSONP: link Note that the remote page must support this format. (as does the google api for instance)





相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签