Re: Strange string behavior...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David OBrien wrote:

> On Wed, Aug 13, 2014 at 10:41 AM, Don Wieland <donw@xxxxxxxxxxxxxxxxxx>
> wrote:
> 
>> I have an issue with updating a text field called "appt_notes" with a
>> string that uses the & and + characters. On one of the forms (which uses
>> AJAX), it does not save the entire text.

<snip>

>>                 $.ajax({
>>                         url: "/utils.php",
>>
>>                         type: "POST",
>>
>>                         data: data,
>
> on the javascript side you'd use  escape( variable ) to add slashes where
> needed on all those variables

escape() is deprecated[1]; it's better to use encodeURI() resp.
encodeURIComponent() instead.  However, in this case the Ajax request is
done with jQuery.ajax() so it is sufficient to set the data property to
an appropriate object[2].  Most likely it is even possible to simplify
the code considerably by using .serialize()[3].

[1]
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/escape>
[2] <http://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings>
[3] <http://api.jquery.com/serialize/>

-- 
Christoph M. Becker

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux