Problems Processing Strings With JS

Last week I encounter a serious problem when trying to use Ajax (PHP/Javascript) to save and update information in MySQL database. The problem is that javascript doesn’t process strings as PHP and decode any string to ASCII format…

The best way around this problem is to use the escape() function.

The way to use this function is like a regular PHP function:


PHP function structure...
functionName(variables);

Javascript ESCAPE function:

var str;
str = escape(document.getElementById('somediv').innerHTML);

This way you can use any special HTML character and stays the way it’s suppose to.

For more info you can go here.

Hope this help any one…

Happy Coding