Note that there are some explanatory texts on larger screens.

plurals
  1. POJSONP: how to construct ajax query?
    primarykey
    data
    text
    <p>I'm trying to work with a JSONP API, across domains. This is an example of the data it returns:</p> <pre><code>photos({"marker":{"@attributes":{"id":"30601","latitude":"52.638061","longitude":"-2.117067","feature":"3","caption":"cat","thumbnailSizes":"60|120|150|180|200|250|300|350|400|400|425|450|500|640"}}}); </code></pre> <p>How can I construct an Ajax call that makes use of this data? I keep getting error messages.</p> <p>This is what I'm trying at the moment: </p> <pre><code>$.ajax({ url: pm_url, data: {}, type: "get", dataType: "jsonp", cache: false, success: function(data) { console.log(data); }, error: function() { alert('Sorry, there was a problem getting the photos!'); } </code></pre> <p>In Firebug, I can see that the data above is being retrieved, but then I see the error message. </p> <p>What is wrong with the request? (Or the data - though it validates as JSONP.)</p> <p>UPDATE:</p> <p>Thanks for the suggestions. I'm now trying: </p> <pre><code> var photos = function (data) { alert(data); }; $.ajax({ url: pm_url, dataType: 'jsonp', jsonpCallback: 'photos', }); </code></pre> <p>This is, weirdly, calling two URLs in Firebug:</p> <pre><code>http://myapi.com/file.jsonp?x=1&amp;y=2?callback=? http://myapi.com/file.jsonp?x=1&amp;y=2?callback=photos&amp;_=1304982373561 </code></pre> <p>The first URL is showing up as an error in the Console. What am I doing wrong?!</p> <p>It's possible that the API itself is wrong (they're requiring a .jsonp suffix and ignoring the value of callback, which is why the function name is fixed) but I was hoping I could work around it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload