I have an API I want to go out to. In a web browser I can return this:
{"files":[{"number":0,"timestamp":1349507580,"time":"20121006071300"},
{"number":1,"timestamp":1349506980,"time":"20121006070300"},
{"number":2,"timestamp":1349506320,"time":"20121006065200"},
{"number":3,"timestamp":1349505720,"time":"20121006064200"},
{"number":12,"timestamp":1349499120,"time":"20121006045200"},
{"number":99,"timestamp":1349446920,"time":"20121005142200"}]}
The server refuses to wrap this like this:
callback( ABOVE DATA )
I have tried to create a php proxy on my localhost to return jsonp data and a callback function but it is not working correctly.
What would be the minimum php code to return the correct jsonp data?
Also what single line of jQuery using ($.ajax ) would be needed to at least output this using alert?
I am only trying to get this to work, which I cannot.
If you made a proxy, then there will not be a cross domain problem. You don’t need to use jsonp, just get the json data and then echo it.