I am using prototype library 1.5.1
Below is the code which uses prototype libraries mathod :
Ajax.Request() to send the ajax req
function submitPost()
{
try{
var url = ''/servlet/CreateDiscussionThread?User=frmÅ å, Ä ä, Ö
ö'';
var pars = ''Email=emailÅ å, Ä ä, Ö ö '';
new
Ajax.Request(url,{method:''get'',contentType:''application/x-www-
form-urlencoded'',encoding:''ISO-8859-1'',parameters:pars,onSuccess:
function(transport){ alert(transport.status);} });
}catch(e){
alert(e);
}
}
In the aboce code u can see that I have passed parameter in two
ways
1.) I have added one parameter directly in url. i.e. User
url = ''/servlet/CreateDiscussionThread?User=frmÅ å, Ä ä, Ö
ö'';
2.) other parameter ie. Email, I am passing as Ajax parameters.
Problem :
In InterNet Expolrer
1.) On the server I am not getting characters in correct format for
the parameters which I passed as parameters of Ajax.Request() i.e.
for the Email . The value comes like this
email� å, � ä
2.) But for the parameter which I passed in url it self is in correct
format ( i.e. for the User parameter the value is coming as frmÅ å, Ä
ä, Ö ö)
In Mozilla both the parameter values are not in correct format there
value comes like this.
frm� å, � ä,
email� å, � ä
I have set meta tag also in my HTML page to specify the character
encoding
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
Thanks for your help
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi sughosh,
In both cases, you''re creating the querystring manually - Ajax.Request
also
supports params defined as an object, with member names and values
corresponding to the key-value pairs, e.g.
var pars= { Email: "emailÅ å, Ä ä, Ö ö " }
If you do it this way, the values will get URLencoded for you. As it stands, I
don''t think they will, OTOH?
FWIW, Prototype also has some good stuff for escaping and unescaping
non-standard characters as HTML entities, which can be another source of
headaches with international character sets.
HTH
Dave
On Tuesday 22 May 2007 16:49, sughosh wrote:> I am using prototype library 1.5.1
>
> Below is the code which uses prototype libraries mathod :
> Ajax.Request() to send the ajax req
>
> function submitPost()
> {
> try{
> var url = ''/servlet/CreateDiscussionThread?User=frmÅ å, Ä ä, Ö
ö'';
> var pars = ''Email=emailÅ å, Ä ä, Ö ö '';
> new
Ajax.Request(url,{method:''get'',contentType:''application/x-www-
>
form-urlencoded'',encoding:''ISO-8859-1'',parameters:pars,onSuccess:
> function(transport){ alert(transport.status);} });
> }catch(e){
> alert(e);
> }
> }
>
>
>
> In the aboce code u can see that I have passed parameter in two
> ways
> 1.) I have added one parameter directly in url. i.e. User
> url = ''/servlet/CreateDiscussionThread?User=frmÅ å, Ä ä, Ö
ö'';
>
> 2.) other parameter ie. Email, I am passing as Ajax parameters.
>
> Problem :
> In InterNet Expolrer
> 1.) On the server I am not getting characters in correct format for
> the parameters which I passed as parameters of Ajax.Request() i.e.
> for the Email . The value comes like this
> email� å, � ä
>
> 2.) But for the parameter which I passed in url it self is in correct
> format ( i.e. for the User parameter the value is coming as frmÅ å, Ä
> ä, Ö ö)
>
> In Mozilla both the parameter values are not in correct format there
> value comes like this.
> frm� å, � ä,
> email� å, � ä
>
>
> I have set meta tag also in my HTML page to specify the character
> encoding
> <meta http-equiv="content-type" content="text/html;
> charset=ISO-8859-1">
>
>
> Thanks for your help
>
>
> >
>
> --
> This email has been verified as Virus free
> Virus Protection and more available at http://www.plus.net
--
----------------------
Author
Ajax in Action http://manning.com/crane
Ajax in Practice http://manning.com/crane2
Prototype & Scriptaculous in Action http://manning.com/crane3
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
...I recently found: encodeURIComponent(). Works nicely in avoiding
crashing due to special characters (#, & ,%, etc). See example below.
Also been wondering though, could I do this a cleaner way that I''m not
aware
of??
cheers,
Mark
function SomeFunction(textparam1, textparam2) {
// wherever the user has the ability to pass in special
characters,
// we need to escape out of those characters before passing:
var passParam1 = encodeURIComponent(textparam1);
var passParam2 = encodeURIComponent(textparam2);
var pars = ''FORM.Param1='' + passParam1 +
''&FORM.Param2='' +
passParam2 ;
var resultDomElem = ''divResult''; //divID;
new Ajax.Updater(resultDomElem, ''[path to server side
calling
page]'',
{
asynchronous:true,
parameters: pars,
onSuccess:function(){
Element.setOpacity(resultDomElem, 0.0, {queue:
{position:''end'', scope: ''scope1''} });
Effect.Appear(resultDomElem, { duration: 1.0 }, {queue:
{position:''end'', scope: ''scope1''} } );
}
}
);
}
On 5/23/07, Dave Crane
<dave-qrf20pp95eSLQvtTh0HkdajZmZ73YKuj@public.gmane.org>
wrote:>
>
> Hi sughosh,
>
> In both cases, you''re creating the querystring manually -
Ajax.Requestalso
> supports params defined as an object, with member names and values
> corresponding to the key-value pairs, e.g.
>
> var pars= { Email: "emailÅ å, Ä ä, Ö ö " }
>
> If you do it this way, the values will get URLencoded for you. As it
> stands, I
> don''t think they will, OTOH?
>
> FWIW, Prototype also has some good stuff for escaping and unescaping
> non-standard characters as HTML entities, which can be another source of
> headaches with international character sets.
>
> HTH
>
> Dave
>
>
> On Tuesday 22 May 2007 16:49, sughosh wrote:
> > I am using prototype library 1.5.1
> >
> > Below is the code which uses prototype libraries mathod :
> > Ajax.Request() to send the ajax req
> >
> > function submitPost()
> > {
> > try{
> > var url = ''/servlet/CreateDiscussionThread?User=frmÅ å, Ä
ä, Ö ö'';
> > var pars = ''Email=emailÅ å, Ä ä, Ö ö '';
> > new
Ajax.Request(url,{method:''get'',contentType:''application/x-www-
> >
form-urlencoded'',encoding:''ISO-8859-1'',parameters:pars,onSuccess:
> > function(transport){ alert(transport.status);} });
> > }catch(e){
> > alert(e);
> > }
> > }
> >
> >
> >
> > In the aboce code u can see that I have passed parameter in two
> > ways
> > 1.) I have added one parameter directly in url. i.e. User
> > url = ''/servlet/CreateDiscussionThread?User=frmÅ å, Ä ä, Ö
ö'';
> >
> > 2.) other parameter ie. Email, I am passing as Ajax parameters.
> >
> > Problem :
> > In InterNet Expolrer
> > 1.) On the server I am not getting characters in correct format for
> > the parameters which I passed as parameters of Ajax.Request() i.e.
> > for the Email . The value comes like this
> > email� å, � ä
> >
> > 2.) But for the parameter which I passed in url it self is in correct
> > format ( i.e. for the User parameter the value is coming as frmÅ å, Ä
> > ä, Ö ö)
> >
> > In Mozilla both the parameter values are not in correct format there
> > value comes like this.
> > frm� å, � ä,
> > email� å, � ä
> >
> >
> > I have set meta tag also in my HTML page to specify the character
> > encoding
> > <meta http-equiv="content-type" content="text/html;
> > charset=ISO-8859-1">
> >
> >
> > Thanks for your help
> >
> >
> > >
> >
> > --
> > This email has been verified as Virus free
> > Virus Protection and more available at http://www.plus.net
>
> --
> ----------------------
> Author
> Ajax in Action http://manning.com/crane
> Ajax in Practice http://manning.com/crane2
> Prototype & Scriptaculous in Action http://manning.com/crane3
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi Deve,
Thx for ur help,
Dave below is the actual code, As u can see I am sending the data in
JSON format means as
a Key:value pair.
But even in this way , at server side the swedish characters are not
coming correctly. I am not able to figure out what is the reason, what
thing I am missing in above code.
Today i tried doing the same thing with regular ajax syntax means
creating xmlHttp object ,setting the headers and sending the data, and
To enocde the data I used escape() method, in this way I am getting
the content correctly.
But why this is not happening when I am using prototype''s method. :-(
while prototype itself internally does all these encoding,
var objHash = new Hash({});
objHash.merge({ qpName:settings.qpName,
dbName:settings.dbName,userId:settings.userId,folderId:settings.folderId});
objHash.merge({subject:$(''subject01'').value});
objHash.merge({body:body});
objHash.merge({parentUNID:parentThread});
objHash.merge({mainPostId:mainPost});
var pars = objHash.toJSON();
var url = ''/servlet/CreateDiscussionThread'';
new Ajax.Request(url,
{method:''post'',contentType:''application/x-www-
form-
urlencoded'',encoding:''ISO-8859-1'',onSuccess:this.handleResponse,postBody:pars});
thx once again
On May 23, 5:28 pm, Dave Crane
<d...-qrf20pp95eSLQvtTh0HkdajZmZ73YKuj@public.gmane.org>
wrote:> Hi sughosh,
>
> In both cases, you''re creating the querystring manually -
Ajax.Request also
> supports params defined as an object, with member names and values
> corresponding to the key-value pairs, e.g.
>
> var pars= { Email: "emailÅ å, Ä ä, Ö ö " }
>
> If you do it this way, the values will get URLencoded for you. As it
stands, I
> don''t think they will, OTOH?
>
> FWIW, Prototype also has some good stuff for escaping and unescaping
> non-standard characters as HTML entities, which can be another source of
> headaches with international character sets.
>
> HTH
>
> Dave
>
> On Tuesday 22 May 2007 16:49, sughosh wrote:
>
>
>
> > I am using prototype library 1.5.1
>
> > Below is the code which uses prototype libraries mathod :
> > Ajax.Request() to send the ajax req
>
> > function submitPost()
> > {
> > try{
> > var url = ''/servlet/CreateDiscussionThread?User=frmÅ å, Ä
ä, Ö ö'';
> > var pars = ''Email=emailÅ å, Ä ä, Ö ö '';
> > new
Ajax.Request(url,{method:''get'',contentType:''application/x-www-
> >
form-urlencoded'',encoding:''ISO-8859-1'',parameters:pars,onSuccess:
> > function(transport){ alert(transport.status);} });
> > }catch(e){
> > alert(e);
> > }
> > }
>
> > In the aboce code u can see that I have passed parameter in two
> > ways
> > 1.) I have added one parameter directly in url. i.e. User
> > url = ''/servlet/CreateDiscussionThread?User=frmÅ å, Ä ä, Ö
ö'';
>
> > 2.) other parameter ie. Email, I am passing as Ajax parameters.
>
> > Problem :
> > In InterNet Expolrer
> > 1.) On the server I am not getting characters in correct format for
> > the parameters which I passed as parameters of Ajax.Request() i.e.
> > for the Email . The value comes like this
> > email� å, � ä
>
> > 2.) But for the parameter which I passed in url it self is in correct
> > format ( i.e. for the User parameter the value is coming as frmÅ å, Ä
> > ä, Ö ö)
>
> > In Mozilla both the parameter values are not in correct format there
> > value comes like this.
> > frm� å, � ä,
> > email� å, � ä
>
> > I have set meta tag also in my HTML page to specify the character
> > encoding
> > <meta http-equiv="content-type" content="text/html;
> > charset=ISO-8859-1">
>
> > Thanks for your help
>
> > --
> > This email has been verified as Virus free
> > Virus Protection and more available athttp://www.plus.net
>
> --
> ----------------------
> Author
> Ajax in Actionhttp://manning.com/crane
> Ajax in Practicehttp://manning.com/crane2
> Prototype & Scriptaculous in Actionhttp://manning.com/crane3
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
sughosh wrote:> var objHash = new Hash({}); > objHash.merge({ qpName:settings.qpName, > dbName:settings.dbName,userId:settings.userId,folderId:settings.folderId}); > objHash.merge({subject:$(''subject01'').value}); > objHash.merge({body:body}); > objHash.merge({parentUNID:parentThread}); > objHash.merge({mainPostId:mainPost}); > var pars = objHash.toJSON();This is a very inefficient way to write it. Try this instead: var objHash = { qpName : settings.qpName, dbName : settings.dbName, userId : settings.userId, folderId : settings.folderI, subject : $(''subject01'').value, body : body, parentUNID : parentThread, mainPostId : mainPost }; var pars = $H(objHash).toJSON(); It avoids the overhead of all those merge calls and is more declarative. But even then, it''s not quite the right way to pass post arguments.> var url = ''/servlet/CreateDiscussionThread''; > new Ajax.Request(url, {method:''post'',contentType:''application/x-www- > form- > urlencoded'',encoding:''ISO-8859-1'',onSuccess:this.handleResponse,postBody:pars});Why are you using ''ISO-8859-1'' and not utf8? Also, why are you turning your name value pairs into JSON and putting them into the post body? Why not just send them as arguments for the POST itself? new Ajax.Request(url, { method : ''post'', parameters : objHash }); Then Prototype will take care of encoding each key and value of the hash you''re passing. -- Michael Peters Developer Plus Three, LP --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Michael, Whenever passing free form text, to prevent my app from choking on special characters, I wrap the variables that could have special characters in encodeURIComponent(textparam1) ... seems to work nicely. Your thoughts? -Mark On 5/24/07, Michael Peters <mpeters-aUYv5hkjw45l57MIdRCFDg@public.gmane.org> wrote:> > > sughosh wrote: > > > var objHash = new Hash({}); > > objHash.merge({ qpName:settings.qpName, > > dbName:settings.dbName,userId:settings.userId,folderId:settings.folderId > }); > > objHash.merge({subject:$(''subject01'').value}); > > objHash.merge({body:body}); > > objHash.merge({parentUNID:parentThread}); > > objHash.merge({mainPostId:mainPost}); > > var pars = objHash.toJSON(); > > This is a very inefficient way to write it. Try this instead: > > var objHash = { > qpName : settings.qpName, > dbName : settings.dbName, > userId : settings.userId, > folderId : settings.folderI, > subject : $(''subject01'').value, > body : body, > parentUNID : parentThread, > mainPostId : mainPost > }; > var pars = $H(objHash).toJSON(); > > It avoids the overhead of all those merge calls and is more declarative. > But > even then, it''s not quite the right way to pass post arguments. > > > var url = ''/servlet/CreateDiscussionThread''; > > new Ajax.Request(url, > {method:''post'',contentType:''application/x-www- > > form- > > urlencoded'',encoding:''ISO-8859-1'',onSuccess:this.handleResponse > ,postBody:pars}); > > Why are you using ''ISO-8859-1'' and not utf8? Also, why are you turning > your name > value pairs into JSON and putting them into the post body? Why not just > send > them as arguments for the POST itself? > > new Ajax.Request(url, { > method : ''post'', > parameters : objHash > }); > > Then Prototype will take care of encoding each key and value of the hash > you''re > passing. > > -- > Michael Peters > Developer > Plus Three, LP > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Michael ,
thx for ur constructive arguments :)
I will change the code to more efficient way as u suggested :
var objHash = {> qpName : settings.qpName,
> dbName : settings.dbName,
> userId : settings.userId,
> folderId : settings.folderI,
> subject : $(''subject01'').value,
> body : body,
> parentUNID : parentThread,
> mainPostId : mainPost};
> Why are you using ''ISO-8859-1'' and not utf8?
why I am using this because the Domino web server''s character
encoding is set to ISO-8859-1.
We can not say client to change those server settings. :-(
even I tried using UTF-8 also in my code, but there was no effect of
that, and I think this is due to those server settings.
>Also, why are you turning your name
> value pairs into JSON and putting them into the post body? Why not just
send
> them as arguments for the POST itself?
The reason to convert it into the JSON is, at server side the SERVLET
reads these content in a string and BUILDs a JSON object, and the JSON
object needs that string to be converted to json must be correctly
formated,
and prototypes toJSON() method does that task,
On May 24, 6:51 pm, Michael Peters
<mpet...-aUYv5hkjw45l57MIdRCFDg@public.gmane.org>
wrote:> sughosh wrote:
> > var objHash = new Hash({});
> > objHash.merge({ qpName:settings.qpName,
> >
dbName:settings.dbName,userId:settings.userId,folderId:settings.folderId});
> > objHash.merge({subject:$(''subject01'').value});
> > objHash.merge({body:body});
> > objHash.merge({parentUNID:parentThread});
> > objHash.merge({mainPostId:mainPost});
> > var pars = objHash.toJSON();
>
> This is a very inefficient way to write it. Try this instead:
>
> var objHash = {
> qpName : settings.qpName,
> dbName : settings.dbName,
> userId : settings.userId,
> folderId : settings.folderI,
> subject : $(''subject01'').value,
> body : body,
> parentUNID : parentThread,
> mainPostId : mainPost};
>
> var pars = $H(objHash).toJSON();
>
> It avoids the overhead of all those merge calls and is more declarative.
But
> even then, it''s not quite the right way to pass post arguments.
>
> > var url = ''/servlet/CreateDiscussionThread'';
> > new Ajax.Request(url,
{method:''post'',contentType:''application/x-www-
> > form-
> >
urlencoded'',encoding:''ISO-8859-1'',onSuccess:this.handleResponse,postBody:pars});
>
> Why are you using ''ISO-8859-1'' and not utf8? Also, why
are you turning your name
> value pairs into JSON and putting them into the post body? Why not just
send
> them as arguments for the POST itself?
>
> new Ajax.Request(url, {
> method : ''post'',
> parameters : objHash
>
> });
>
> Then Prototype will take care of encoding each key and value of the hash
you''re
> passing.
>
> --
> Michael Peters
> Developer
> Plus Three, LP
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi Mark, thx for ur help, I will give a try to this & let u know the result. On May 23, 10:59 pm, "Mark Holton" <holto...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ...I recently found: encodeURIComponent(). Works nicely in avoiding > crashing due to special characters (#, & ,%, etc). See example below. > > Also been wondering though, could I do this a cleaner way that I''m not aware > of?? > cheers, > Mark > > function SomeFunction(textparam1, textparam2) { > > // wherever the user has the ability to pass in special > characters, > // we need to escape out of those characters before passing: > > var passParam1 = encodeURIComponent(textparam1); > var passParam2 = encodeURIComponent(textparam2); > > var pars = ''FORM.Param1='' + passParam1 + ''&FORM.Param2='' + > passParam2 ; > > var resultDomElem = ''divResult''; //divID; > > new Ajax.Updater(resultDomElem, ''[path to server side calling > page]'', > { > asynchronous:true, > parameters: pars, > onSuccess:function(){ > Element.setOpacity(resultDomElem, 0.0, {queue: > {position:''end'', scope: ''scope1''} }); > Effect.Appear(resultDomElem, { duration: 1.0 }, {queue: > {position:''end'', scope: ''scope1''} } ); > } > } > ); > } > > On 5/23/07, Dave Crane <d...-qrf20pp95eSLQvtTh0HkdajZmZ73YKuj@public.gmane.org> wrote: > > > > > Hi sughosh, > > > In both cases, you''re creating the querystring manually - Ajax.Requestalso > > supports params defined as an object, with member names and values > > corresponding to the key-value pairs, e.g. > > > var pars= { Email: "emailÅ å, Ä ä, Ö ö " } > > > If you do it this way, the values will get URLencoded for you. As it > > stands, I > > don''t think they will, OTOH? > > > FWIW, Prototype also has some good stuff for escaping and unescaping > > non-standard characters as HTML entities, which can be another source of > > headaches with international character sets. > > > HTH > > > Dave > > > On Tuesday 22 May 2007 16:49, sughosh wrote: > > > I am using prototype library 1.5.1 > > > > Below is the code which uses prototype libraries mathod : > > > Ajax.Request() to send the ajax req > > > > function submitPost() > > > { > > > try{ > > > var url = ''/servlet/CreateDiscussionThread?User=frmÅ å, Ä ä, Ö ö''; > > > var pars = ''Email=emailÅ å, Ä ä, Ö ö ''; > > > new Ajax.Request(url,{method:''get'',contentType:''application/x-www- > > > form-urlencoded'',encoding:''ISO-8859-1'',parameters:pars,onSuccess: > > > function(transport){ alert(transport.status);} }); > > > }catch(e){ > > > alert(e); > > > } > > > } > > > > In the aboce code u can see that I have passed parameter in two > > > ways > > > 1.) I have added one parameter directly in url. i.e. User > > > url = ''/servlet/CreateDiscussionThread?User=frmÅ å, Ä ä, Ö ö''; > > > > 2.) other parameter ie. Email, I am passing as Ajax parameters. > > > > Problem : > > > In InterNet Expolrer > > > 1.) On the server I am not getting characters in correct format for > > > the parameters which I passed as parameters of Ajax.Request() i.e. > > > for the Email . The value comes like this > > > emailÃ? Ã¥, Ã? ä > > > > 2.) But for the parameter which I passed in url it self is in correct > > > format ( i.e. for the User parameter the value is coming as frmÅ å, Ä > > > ä, Ö ö) > > > > In Mozilla both the parameter values are not in correct format there > > > value comes like this. > > > frmÃ? Ã¥, Ã? ä, > > > emailÃ? Ã¥, Ã? ä > > > > I have set meta tag also in my HTML page to specify the character > > > encoding > > > <meta http-equiv="content-type" content="text/html; > > > charset=ISO-8859-1"> > > > > Thanks for your help > > > > -- > > > This email has been verified as Virus free > > > Virus Protection and more available athttp://www.plus.net > > > -- > > ---------------------- > > Author > > Ajax in Actionhttp://manning.com/crane > > Ajax in Practicehttp://manning.com/crane2 > > Prototype & Scriptaculous in Actionhttp://manning.com/crane3--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Mark Holton wrote:> Michael, > Whenever passing free form text, to prevent my app from choking on > special characters, I wrap the variables that could have special > characters in encodeURIComponent( textparam1) ... seems to work nicely. > Your thoughts?That''s what Prototype does behind the scenes when you pass in an object for parameters instead of strings. -- Michael Peters Developer Plus Three, LP --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
great to know, which is why I brought up the point a couple times. Really appreciate that info. I have been manually sending in params outside of a JSON object (therefore they required cleaning with encodeURIComponent), but sounds like it''s most efficient to send via JSON and have Prototype take care of the cleansing inherently. I''ll give it a whirl, many thanks, Michael! On 5/24/07, Michael Peters <mpeters-aUYv5hkjw45l57MIdRCFDg@public.gmane.org> wrote:> > > Mark Holton wrote: > > Michael, > > Whenever passing free form text, to prevent my app from choking on > > special characters, I wrap the variables that could have special > > characters in encodeURIComponent( textparam1) ... seems to work nicely. > > Your thoughts? > > That''s what Prototype does behind the scenes when you pass in an object > for > parameters instead of strings. > > -- > Michael Peters > Developer > Plus Three, LP > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thx to all of u for ur help and suggestion. My Problem is sloved now. What I understood abt the reason of character encoding problem is : prototype internally encodes the parameters using encodeURIComponent(), which uses UTF-8 encoding, but in my case server expects the data to be in ISO-8859-1 encoding. And it tries to decode the content thinking that content are encoded in ISO-8859-1 encoding. So to solve that I have used escape() which encodes the data in ISO-8859-1, and that solved my problem. actually both these methods : encodeURI() or encodeURIComponent() uses UTF-8 encoding, and if ur server expect the data to be in ISO-8859-1 then I think better to use escape() instead of encodeURI() or encodeURIComponent(). (plz correct me If I am wrong here.) On May 24, 10:47 pm, "Mark Holton" <holto...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> great to know, which is why I brought up the point a couple times. Really > appreciate that info. > > I have been manually sending in params outside of a JSON object (therefore > they required cleaning with encodeURIComponent), but sounds like it''s most > efficient to send via JSON and have Prototype take care of the cleansing > inherently. I''ll give it a whirl, many thanks, Michael! > > On 5/24/07, Michael Peters <mpet...-aUYv5hkjw45l57MIdRCFDg@public.gmane.org> wrote: > > > > > Mark Holton wrote: > > > Michael, > > > Whenever passing free form text, to prevent my app from choking on > > > special characters, I wrap the variables that could have special > > > characters in encodeURIComponent( textparam1) ... seems to work nicely. > > > Your thoughts? > > > That''s what Prototype does behind the scenes when you pass in an object > > for > > parameters instead of strings. > > > -- > > Michael Peters > > Developer > > Plus Three, LP--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Because prtotype uses encodeURI() or encodeURIComponent() the data is encoded in UTF-8, Is there is any way in prototype to encode the data to be sent in ISO-8859-1, instead of UTF-8. On May 25, 2:00 pm, sughosh <sughos...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thx to all of u for ur help and suggestion. > > My Problem is sloved now. > > What I understood abt the reason of character encoding problem is : > prototype internally encodes the parameters using > encodeURIComponent(), which uses UTF-8 encoding, > but in my case server expects the data to be in ISO-8859-1 > encoding. > And it tries to decode the content thinking that content are > encoded in ISO-8859-1 encoding. > > So to solve that I have used escape() which encodes the data in > ISO-8859-1, > and that solved my problem. > > actually both these methods : encodeURI() or encodeURIComponent() > uses UTF-8 encoding, > and if ur server expect the data to be in ISO-8859-1 then I think > better to use escape() instead of encodeURI() or > encodeURIComponent(). (plz correct me If I am wrong here.) > > On May 24, 10:47 pm, "Mark Holton" <holto...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > great to know, which is why I brought up the point a couple times. Really > > appreciate that info. > > > I have been manually sending in params outside of a JSON object (therefore > > they required cleaning with encodeURIComponent), but sounds like it''s most > > efficient to send via JSON and have Prototype take care of the cleansing > > inherently. I''ll give it a whirl, many thanks, Michael! > > > On 5/24/07, Michael Peters <mpet...-aUYv5hkjw45l57MIdRCFDg@public.gmane.org> wrote: > > > > Mark Holton wrote: > > > > Michael, > > > > Whenever passing free form text, to prevent my app from choking on > > > > special characters, I wrap the variables that could have special > > > > characters in encodeURIComponent( textparam1) ... seems to work nicely. > > > > Your thoughts? > > > > That''s what Prototype does behind the scenes when you pass in an object > > > for > > > parameters instead of strings. > > > > -- > > > Michael Peters > > > Developer > > > Plus Three, LP--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---