开发者

jquery post to PhishTank

开发者 https://www.devze.com 2023-01-18 22:10 出处:网络
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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号