1 Attachment(s)
[RESOLVED] Wow - can't pass ?? in ajax web service call
I cannot pass ?? as data in a JSON object to a web service.
One ? will save - two (??) will not!
The image below shows the $.ajax call - it never makes it to the VB web service (I set a break point in that code) - it appears to be getting rejected by the IIS process.
Interestingly enough you can see that I'm passing in "a??" as the data - and the "parseerror" is coming back with the "a??" changed to
"ajQuery15204.........."
I did read about ?? being some kind of php query separator - I'm not using php...
What the heck is going on here??
Re: Wow - can't pass ?? in ajax web service call
The question mark is a control character in HTTP requests.
Check out
http://stackoverflow.com/questions/5...cutive-questio
Re: Wow - can't pass ?? in ajax web service call
Thanks - that link deals directly with this problem - although I'm not sure I see a simple answer in that link - I've to to eat dinner and come back to this later!
Re: Wow - can't pass ?? in ajax web service call
That link was all over the place - and the solutions offered were not strong.
Did you google for that - or do you know that to be a solution to this issue?
I'm about this "close" to escaping the ?? marks - can I do that somehow?
Like with
\u#### for the question marks?
Or do I have to roll my own internal escaping for this?
Re: Wow - can't pass ?? in ajax web service call
I couldn't reproduce your issue. It could be that it has been fixed in the jQuery source.
This works for me using jQuery 1.7.1:
Code:
var obj = { 'foo': '??' };
$.ajax({
type: 'POST',
url: 'http://localhost/test10.php',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify(obj),
success: function(msg) {
console.info(msg);
}
});
This sends the JSON string as the body of the POST request. While this is valid HTTP, it is atypical. Usually POST requests consist of a set of name/value pairs, which is denoted by the content type application/x-www-form-urlencoded.
You can send a request of this form using $.post:
Code:
$.post(
'http://localhost/test10.php',
{'json': JSON.stringify(obj)},
function(msg) {
console.info(msg);
}
);
Note that in this case, the JSON string is passed as a parameter named 'json'.
Re: Wow - can't pass ?? in ajax web service call
Yes - it's fixed in jQuery 1.7.1
Here was the bug ticket - seems they didn't believe/understand the problem for quite a while!
http://bugs.jquery.com/ticket/8417
btw - I'm talking to asp.net web services with this app - so IIS is doing the unraveling of the ajax calls...