I have a page being served from a Web.API app located at http://server/application
. On the client side, I am doing a GET to pull some data from the servers. The problem is what I thought should work does not.
This code works:
$.ajax( {
url: "api/slideid/getdirectories/",
dataType: 'json',
success: function ( data ) {
setPaths( data );
}
} );
But this does not:
$.getJSON( "api/slideid/getdirectories/",
function ( data ) {
setPaths( data );
} );
In the first example I see in fiddler that the url it is trying to retrieve the data from is http://server/application/api/slideid/getdirectories
, which is correct.
In the second, it is http://server/api/slideid/getdirectories
, which is not right. I was thinking that these two methods of json GET were the same.... but it seems they are not?
Interestingly, BOTH these methods work on my local dev box- it is only on my staging server that one works and the other does not. IIS settings are identical as far as I can tell- and I dug in pretty good to check.
So I'm wondering why getJSON does not work, when the jQuery docs state that getJSON is just shorthand for the .ajax call?
EDIT: I had put in an explicit version of getJSON hoping to show that they were very similar calls, but the 'real' getJSON call is now there.