0

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)); });

Dr Hydralisk
  • 1,171
  • 4
  • 14
  • 22

2 Answers2

2

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.

Community
  • 1
  • 1
CharlesLeaf
  • 3,201
  • 19
  • 16
0

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

Mike G
  • 4,713
  • 2
  • 28
  • 31