williamsandonz
williamsandonz

Reputation: 16440

JSONP requests to external domain with jquery

Can these be done without writing any server side code?

Would like to handle the API call to an external website myself with jQuery but if it requires ANY server side coding then I can't be bothered with JSONP would rather just make the call server-side and output a JSON variable in a <script="text/javascript></script> tag.

Upvotes: 0

Views: 513

Answers (2)

thecodeparadox
thecodeparadox

Reputation: 87073

<script>
    $.getJSON("http://yourapiurl?jsoncallback=?", {data as object format if you want},
    function(data) {
       // do what u wish with response `data`
    });
</script>

Upvotes: 1

James Montagne
James Montagne

Reputation: 78740

If the service supports jsonp then there is no server-side code required by you. That's the point of jsonp.

Upvotes: 1

Related Questions