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 <[EMAIL PROTECTED]> 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 [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
-~----------~----~----~----~------~----~------~--~---

Reply via email to