Cross domain Request

As it known to all, javascript has one- domain policy.That is to say we cannot directly send request to another website.

There are 2 methods to solve this situation

1. Using jsonp in ajax.

 $.ajax({
            type:”GET”,
            url :yahooURL,
            dataType:”jsonp”,
            jsonp: false,
            success: function(response){

                var wind = window.open(“”, “popupWindow”, “width=600,height=600,scrollbars=yes”);
                wind.document.write(response);
            }
});
Jsonp is the only type in ajax that  allow cross domain request.But the problem is that the response data type must be jsonp as well.

2.CORS

CORS also use XMLHttpRequest to send request.
The problem is that if we want to use CORS we need to set the sever side.
However ,sometime we can not set the config file on the server side.

There is  another way to do it .link :
http://code.tutsplus.com/tutorials/quick-tip-cross-domain-ajax-request-with-yql-and-jquery–net-10225

13 Replies to “Cross domain Request”

  1. I like the valuable info you provide in your articles. I
    will bookmark your blog and check again here
    frequently. I am quite certain I’ll learn many new stuff right
    here! Good luck for the next!

  2. of course like your website but you have to check the spelling on several of
    your posts. A number of them are rife with spelling
    problems and I find it very troublesome to
    inform the reality then again I will definitely come back again.

  3. Just want to say your article is as amazing.
    The clarity in your post is just excellent and i can assume you are an expert on this subject.
    Fine with your permission let me to grab your RSS feed to keep up to
    date with forthcoming post. Thanks a million and please carry on the gratifying
    work.

  4. Having read this I thought it was really enlightening. I appreciate you spending
    some time and energy to put this article together. I once
    again find myself spending way too much time both reading and leaving comments.
    But so what, it was still worth it!

  5. Hello! This post couldn’t be written any better! Reading this post reminds me of my previous room mate!
    He always kept talking about this. I will forward this page to him.
    Fairly certain he will have a good read. Thank you for
    sharing!

  6. Hmm is anyone else experiencing problems with the pictures on this blog loading?
    I’m trying to figure out if its a problem on my end or if it’s the
    blog. Any suggestions would be greatly appreciated.

  7. Excellent site you have here but I was wanting to know if you knew of any
    discussion boards that cover the same topics discussed here?
    I’d really love to be a part of community where I can get responses from other knowledgeable people that
    share the same interest. If you have any recommendations, please let me know.
    Bless you!

  8. Greetings from Los angeles! I’m bored at work so I decided to browse your site on my iphone during lunch break.
    I really like the info you present here and can’t wait to take a look
    when I get home. I’m surprised at how quick your blog loaded
    on my cell phone .. I’m not even using WIFI, just 3G ..

    Anyways, very good site!

Leave a Reply

Your email address will not be published. Required fields are marked *