tags:

views:

17

answers:

2

I am new to jQuery and have been trying to query the PhishTank API 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)); });

+2  A: 

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.

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.

CharlesLeaf
Thanks, I suspected that is why it would not work.
Dr Hydralisk
A: 

You can't do cross-domain requests. See "Additional Notes" section: jQuery.post

MikeG