Take the 2-minute tour ×

I have an HTML and JavaScript file set up to retreive data from a JSONP enabled web service. My problem is that when I deploy the html and .js file to the directory where the service is running it will execute fine, but if I try to run the html and .js file from another host, the request doesn't make it to the web service and the java script gives me a server 500 error.

I'm using Chrome's developer tools to see the xmlhttprequest call which is the only reason I know I'm getting the 500 error.

I've already done quite a bit of research and found that I need to have the script method tag set with the response type set to json and the usehttpget set to true, and I've done these two things as well as tried setting up a clientaccesspolicy.xml in the project as was mentioned by another post. All to no avail.

I'm sure this is a configuration issue on the web service or IIS side as when I put the html and javascript files in the directory of my code and run the web service through the IDE, I can use that instance of the html to call the web service and I get my response fine. But if the html and javascript isn't in the working directory of the code being ran, I get a server error 500.

How can this be solved?

EDIT I also found a post saying that the 500 error was based on the request size so I added < jsonSerialization maxJsonLength="5000000" / > to my web.config to no help.

share|improve this question
add comment

1 Answer

I don't know much about IIS configuration, but if you are trying to use JSONP to get around a cross-domain issue, then you should not see an XMLHttpRequest. The way JSONP works is that you inject a script tag with the url you are trying to call:

var tag = document.createElement("script")
tag.src = "http://someurl.example.com?args=42&callback=wrapperFunction"

The server then uses the callback querystring argument to wrap it's response in a functioncall, like this:

wrapperFunction({some: 'response', arg: 42});

The reason this works is that script-tags doesn't have to follow cross-domain policies, so if you aren't doing it this way, then you are not using JSONP and you have to obey the cross-domain rules.

I apologize if this really is a problem with the IIS configuration, I just saw XMLHttpRequest mentioned together with JSONP, and tought "hey that's wrong!". I hope it's helpful, else just disregard it :-)

share|improve this answer
the xmlhttprequest was just the portion of the Chrome Java Script debugger that allowed me to see the JSON formatted response. I actually now have it working by implementing a version of a class that I initially found on the internet and later found that the group that coded the java script appears to also have used. The code I'm using is based on the JsonHttpModule class found about half way down this article From CodeProject I did have to convert it to VB... but my problem now is that I'm getting multiple JQUERY tags back. –  jnusz Aug 2 '11 at 15:44
Ran out of space... here's a sample of my response: jQuery1620976034790975973_1312299185126(jQuery1620976034790975973_1312299185126(‌​);jQuery1620976034790975973_1312299185126({"d":{"__type":"OrionNetWebServices.CIPa‌​dResponse+CValidateTDACResponse","Success":false,"CenterName":"","FirstName":"","‌​LastName":"","ErrorMessage":"Unable to validate Temporary Device Activation. An unkown error has been encountered. Please contact OrionNet Systems for further assistance.","ErrorAction":"none"}});jQuery1620976034790975973_1312299185126();)‌​; Any help on why i'm getting the extra would be appreciated. –  jnusz Aug 2 '11 at 15:48
OK, I feel like an idiot for my last 2 posts. I found the problem and it was that I had tried to implement the response filter one way and then another. The problem was that I didn't take out my web.config references for the first way from my web.config in the root of my iis. @AHM, thanks for the attempt at helping. –  jnusz Aug 2 '11 at 18:29
add comment

Your Answer


