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" <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---