Note that there are some explanatory texts on larger screens.

plurals
  1. POSolving this issue of sending arabic characters using ajax
    primarykey
    data
    text
    <p>I'm using an AJAX form in order to send data to another page named 'show.php'. Here is the source of pages:</p> <p><strong>form.html</strong></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt; &lt;script src="ajaxsbmt.js" type="text/javascript"&gt;&lt;/script&gt; &lt;/head&gt; &lt;div id="MyResult"&gt;&lt;/div&gt; &lt;form method="POST" action="response_norma.php" name="MyForm" onsubmit="xmlhttpPost('show.php', 'MyForm', 'MyResult', '&lt;img src=\'indicator.gif\'&gt;'); return false;"&gt; &lt;input type="text" name="mytext" size="20"&gt; &lt;input type="submit" value="Submit" name="ok"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>show.php</strong></p> <pre><code>&lt;?php echo $_REQUEST['mytext']; ?&gt; </code></pre> <p><strong>ajaxsbmt.js</strong></p> <pre><code>function xmlhttpPost(strURL, formname, responsediv, responsemsg) { var xmlHttpReq = false; var self = this; // xhr for Mozilla/Safari/Ie7 if (window.XMLHttpRequest) { self.xmlHttpReq = new XMLHttpRequest(); } // xhr for all other versions of IE else if (window.ActiveXObject) { self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } self.xmlHttpReq.open('POST', strURL, true); self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); self.xmlHttpReq.onreadystatechange = function() { if (self.xmlHttpReq.readyState == 4) { // When ready, put the response into the form updatepage(self.xmlHttpReq.responseText, responsediv); } else { // While waiting for the respnse, display a message updatepage(responsemsg, responsediv); } } self.xmlHttpReq.send(getquerystring(formname)); } function getquerystring(formname) { var form = document.forms[formname]; var qstr = ""; function GetElemValue(name, value) { qstr += (qstr.length &gt; 0 ? "&amp;" : "") + escape(name).replace(/\+/g, "%2B") + "=" + escape(value ? value : "").replace(/\+/g, "%2B"); ´//+ escape(value ? value : "").replace(/\n/g, "%0D"); } var elemArray = form.elements; for (var i = 0; i &lt; elemArray.length; i++) { var element = elemArray[i]; var elemType = element.type.toUpperCase(); var elemName = element.name; if (elemName) { if ( elemType == "TEXT" || elemType == "TEXTAREA" || elemType == "PASSWORD" || elemType == "BUTTON" || elemType == "RESET" || elemType == "SUBMIT" || elemType == "FILE" || elemType == "IMAGE" || elemType == "HIDDEN" ) GetElemValue(elemName, element.value); else if (elemType == "CHECKBOX" &amp;&amp; element.checked) GetElemValue(elemName, element.value ? element.value : "On"); else if (elemType == "RADIO" &amp;&amp; element.checked) GetElemValue(elemName, element.value); else if (elemType.indexOf("SELECT") != -1) for (var j = 0; j &lt; element.options.length; j++) { var option = element.options[j]; if (option.selected) GetElemValue(elemName, option.value ? option.value : option.text); } } } return qstr; } function updatepage(str, responsediv) { document.getElementById(responsediv).innerHTML = str; } </code></pre> <p><strong>PROBLEM</strong></p> <p>When I type English characters in the filed, data transfer successfully and I receive them top of the form.</p> <p>But when I try to type Arabic characters, I receive another data, something like encoded words. e.g: %u0633%u0644%u0627%u0645. %u0686%u0637%u0648%u0631%u06CC instead of:<br> سلام. چطوری (if you have font.)</p> <p>How can I solve this problem?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload