Skip to content Skip to sidebar Skip to footer

Return Jsonp From Classic Asp With Javascript Server Side Coding

I'm calling a classic .asp page from jquery to return a list (using JSONP). I want to use JSONP because of the same origin policy that causes problems when my website is viewed thr

Solution 1:

Your example makes no sense. First, it has invalid syntax ("hello world" is a string but it is not quoted). Secondly, you want to encode JSON in your asp code, but using eval would be a (wrong) way to decode JSON. Here is what I think you could do, using Crockford's json2.js to encode your object, like this:

var sourceObj = { "testkey" : "test value", "otherkey" : 5 };
var jsonstr = JSON.stringify(sourceObj);
Response.Write("yourjsonpCallbackName (" + jsonstr + ");");

Post a Comment for "Return Jsonp From Classic Asp With Javascript Server Side Coding"