Barry
Barry

Reputation: 127

Using CLASSIC ASP to return data to jsonp call

I have been through the posts on stackoverflow and cannot seems to find what I am looking for.

If I do (Form:

$.ajaxSettings.dataType    = "jsonp";
$.get('http://MYREMOTESERVER.com/GetCustNewID.asp?callback=?', function() {
     //SOMETHING HERE
     });

On The remote CLASSIC ASP server how, using asp, would I return the id?

This Response.Write "[{""id"": " & Rs("@ID") & "}]" obviously does not work.

Thanks for your help.

Upvotes: 3

Views: 3650

Answers (3)

Jailhouse Joe
Jailhouse Joe

Reputation: 63

Here is the correct way to return jsonp using classic asp. We are not returning json, we are returning json wrapped in a javascript callback function so our response is javascript not json.

Response.ContentType = "application/javascript"

dim callback
callback = Request("callback") // callback querystring contains the callback function name

Response.Write(callback & "({""result"": ""Done""})")

Upvotes: 2

Barry
Barry

Reputation: 127

For those who want to know. The Answer is here: http://forum.jquery.com/topic/classic-asp-and-jsonp-output

Upvotes: 0

mattygs
mattygs

Reputation: 128

There may be an issue with cross-domain ajax depending on browser and/or server settings. I would make sure this is not the issue.

Upvotes: 0

Related Questions