{"id":42,"date":"2010-07-16T15:22:21","date_gmt":"2010-07-16T22:22:21","guid":{"rendered":"http:\/\/www.designersgate.com\/blogs\/?p=42"},"modified":"2010-07-16T15:22:21","modified_gmt":"2010-07-16T22:22:21","slug":"problems-processing-strings-with-js","status":"publish","type":"post","link":"https:\/\/designersgate.com\/blog\/problems-processing-strings-with-js\/","title":{"rendered":"Problems Processing Strings With JS"},"content":{"rendered":"<p>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&#8217;t process strings as PHP and decode any string to ASCII format&#8230;<\/p>\n<p>The best way around this problem is to use the <code>escape()<\/code> function.<\/p>\n<p>The way to use this function is like a regular PHP function:<\/p>\n<p><code><br \/>\nPHP function structure...<br \/>\nfunctionName(variables);<br \/>\n<\/code><\/p>\n<p>Javascript ESCAPE function:<br \/>\n<code><br \/>\nvar str;<br \/>\nstr = escape(document.getElementById('somediv').innerHTML);<br \/>\n<\/code><\/p>\n<p>This way you can use any special HTML character and stays the way it&#8217;s suppose to.<\/p>\n<p>For more info you can go <a href=\"http:\/\/www.w3schools.com\/jsref\/jsref_escape.asp\">here<\/a>.<\/p>\n<p>Hope this help any one&#8230;<\/p>\n<p>Happy Coding<\/p>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/www.w3schools.com\/jsref\/jsref_escape.asp<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[7],"tags":[21,16,22,23,24,25],"class_list":["post-42","post","type-post","status-publish","format-standard","hentry","category-tutorials","tag-escape","tag-javascript","tag-js","tag-strings","tag-unescape","tag-urlencode"],"acf":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/designersgate.com\/blog\/wp-json\/wp\/v2\/posts\/42","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/designersgate.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/designersgate.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/designersgate.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/designersgate.com\/blog\/wp-json\/wp\/v2\/comments?post=42"}],"version-history":[{"count":0,"href":"https:\/\/designersgate.com\/blog\/wp-json\/wp\/v2\/posts\/42\/revisions"}],"wp:attachment":[{"href":"https:\/\/designersgate.com\/blog\/wp-json\/wp\/v2\/media?parent=42"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/designersgate.com\/blog\/wp-json\/wp\/v2\/categories?post=42"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/designersgate.com\/blog\/wp-json\/wp\/v2\/tags?post=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}