jquery post to PhishTank
I am new to jQuery and have been trying to query the PhishTank AP开发者_如何学编程I and in Firebug it returns the url in red and nothing was returned from PhishTank. The code I used is below.
$(document).ready(function() { $.post("http://checkurl.phishtank.com/checkurl/", { url: "http://google.com" }, alert(data)); });
I would like to refer you to this question from yesterday. The top answer (from me) should explain the ins and outs.
Basically, the problem is the XHR Cross Domain Policy - you can't use XHR cross domain. Two ways to solve this, JSONP (which is GET only, basically injects a script
tag. jQuery supports this natively) or build a "proxy" script on your own domain that forwards the request and returns the response to your script. Both are explained in a little more detail in my answer in the added link.
- Odd jQuery problem - Ajax request to a C program not quite working
Cross-Domain POST requests don't work, unless you build a proxy script. So it's JSONP with a GET request (if supported by your webservice), or a proxy script.
You can't do cross-domain requests. See "Additional Notes" section: jQuery.post
精彩评论