问题
I want to load in content from another site (essentially I want to check if something is on the page). I know the same origin policy makes this difficult, but I was wondering if there is a way around it. I looked into using this: http://api.jquery.com/jQuery.getJSON/
Is there a better, simpler way? It looks like that is only for JSON.
Thanks
回答1:
You can use
dataType: "jsonp"
but I believe this requires that the entire page you're loading via ajax be in JSON format (which it probably isn't).
The technique I've used to get around this would be to use a server-side script (like PHP + CURL) to get the page (or check for the information I want) and then use a jQuery ajax call on my server-side script (which is not cross-domain) to get the data I want.
来源:https://stackoverflow.com/questions/9027988/jquery-load-problems-same-origin-policy