If you use a data string like that, it would be recommended, I think.
However, I think it's better to put the data in a JSON object instead,
which you don't have to encode.
the $.ajax 'data' parameter will accept both types.

var dataObj = {name:name};

$.ajax({
                  type: "POST",
                  url: "mail.ajax.php",
                  data: dataObj,
                  dataType: "html"
     });

On Apr 30, 12:16 pm, jb007nd <jmadd...@support.ucla.edu> wrote:
> Do i need to encode my data send through AJAX post?
>
> Ex.
> var name = $("input#name").val();
>
> var dataString = 'name='+ name;
>
> ///////////////////////////////////////////////
> $.ajax({
>                   type: "POST",
>                   url: "mail.ajax.php",
>                   data: dataString,
>                   dataType: "html"
>      });
>
> ///////////////////////////////////////////////
>
> How can I do an URLecode?
>
> thanks!

Reply via email to