Sam,

I'm hoping that by ASP you mean ASP.NET, because there is an easy solution
for this.  The problem lies in the fact that the Server.URLEncode class is
NOT javascript-friendly.

I solved this be accessing the MS javascript engine from within .NET, with:

Microsoft.JScript.GlobalObject.encodeURIComponent(strParmChoices);

This will encode a space as %20, rather than a +.  Also, any number of
special characters are properly converted.

On the client side, use 

decodeURIComponent(val)

You'll probably need to add the Microsoft.Jscript dll to your project.

JK

P.S. This also works with escape and unescape, as in:

SERVER: Microsoft.JScript.GlobalObject.escape(strParmChoices);
CLIENT: unescape(val);


-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of SamCKayak Sent: Monday, May 21, 2007 3:44 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Ajax: ASP returns JSON to client


In ASP, I am building a JSON object and escape the data using 

Server.URLEncode(strParmChoices) 

It seems this encodes blanks as a plus sign "+". 

Back in JavaScript, it looks like unescape("+") leaves the plus as a plus.
I've band-aided the problem using 

unescape(json.strParmChoices).replace(/\+/g, ' '); /* replace all plusses
with blanks */ 

Is there a better way to get this job done right? 

Sam

Reply via email to