I'm trying to develop a drupal module to return json from the citysearch api. I can successfully construct the url and I can use the url to open a new window and display the returned json data, thus:

testwindow= window.open (URL, "mywindow",

however, my attempt to try this with ajax fails, thus:

 type: 'get',
 url: URL,
 dataType: 'jsonp',
 error: function() { alert("Some error"); },
 success: function() { alert("Some success"); }
}); // end ajax method

This always results in the "Some error" alert. I've tried it with 'get' and 'post' for type and with 'json' and 'jsonp' for dataType. No joy. I would appreciate any thoughts on what fundamental points I'm missing here.

8 Years
Discussion Span
Last Post by scottholmes

When the URL is in another domain the underlying XMLHttpRequest will never succeed in some browsers and in others it may be blocked by security settings.


So, what is the secret? How can I read the results of a call to the api, xml or json, into an object? window.open displays the raw json object but does not provide much functionality and if the call fails for some reason it does not report error codes that may be returned. Also, I don't particularly want the results to be displayed in a pop-up window. I get the same 400 error using curl.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.