phpmady Posted May 8, 2010 Share Posted May 8, 2010 Hi, I am getting the ??? in display after i updating table value through ajax. Any Idea? Thanks Link to comment https://forums.phpfreaks.com/topic/201124-unicode-display-problem-when-updating-the-value-through-ajax/ Share on other sites More sharing options...
kenrbnsn Posted May 8, 2010 Share Posted May 8, 2010 We're not mind readers. Please post your code. Ken Link to comment https://forums.phpfreaks.com/topic/201124-unicode-display-problem-when-updating-the-value-through-ajax/#findComment-1055183 Share on other sites More sharing options...
phpmady Posted May 8, 2010 Author Share Posted May 8, 2010 Sorry Ya, This is my code, from onblur of the textbox, am calling the ajax call. html <input type="text" onblur="namechange(this.value,'Menu_Name',{id_val},'Menu_ID','Menu')" value="{Menu_Nameval}"> js code // JavaScript Document var xmlhttp; //function namechange(name_fieldvalue) function namechange(name_fieldvalue,name_fieldname,id_val,id_fieldname,table_name) { /* alert(name_fieldvalue); alert(name_fieldname); alert(id_val); alert(id_fieldname); alert(table_name); */ if (name_fieldvalue.length==0) { document.getElementById("txtHint").innerHTML=""; return; } xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Your browser does not support XMLHTTP!"); return; } var url="ajax_namechange.php"; url=url+"?name_fieldvalue="+name_fieldvalue; url=url+"&name_fieldname="+name_fieldname; url=url+"&id_val="+id_val; url=url+"&id_fieldname="+id_fieldname; url=url+"&table_name="+table_name; xmlhttp.onreadystatechange=stateChanged; xmlhttp.open("GET",url,true); xmlhttp.send(null); } function stateChanged() { if (xmlhttp.readyState==4) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } php code to Update <?php header ('Content-type: text/html; charset=utf-8'); include("global.php"); //get the q parameter from URL $name_fieldvalue=$_POST["name_fieldvalue"]; $name_fieldname=$_POST["name_fieldname"]; $id_val = $_POST["id_val"]; $id_fieldname = $_POST["id_fieldname"]; $table_name = $_POST["table_name"]; $DB_site->query("UPDATE $table_name SET $name_fieldname='".$name_fieldvalue."' WHERE $id_fieldname = '".$id_val."'"); $response = "done1"; //output the response echo $response; ?> We're not mind readers. Please post your code. Ken thank You Link to comment https://forums.phpfreaks.com/topic/201124-unicode-display-problem-when-updating-the-value-through-ajax/#findComment-1055186 Share on other sites More sharing options...
phpmady Posted May 8, 2010 Author Share Posted May 8, 2010 anyone guess that? Link to comment https://forums.phpfreaks.com/topic/201124-unicode-display-problem-when-updating-the-value-through-ajax/#findComment-1055197 Share on other sites More sharing options...
phpmady Posted May 8, 2010 Author Share Posted May 8, 2010 Hi, I am able to make it in firefox but in ie7, i could not update via ajax whats the reason I have just change my js file // JavaScript Document var xmlhttp; //function namechange(name_fieldvalue) function namechange(name_fieldvalue,name_fieldname,id_val,id_fieldname,table_name) { /* alert(name_fieldvalue); alert(name_fieldname); alert(id_val); alert(id_fieldname); alert(table_name); */ function uni2ent(srcTxt) { var entTxt = ''; var c, hi, lo; var len = 0; for (var i=0, code; code=srcTxt.charCodeAt(i); i++) { var rawChar = srcTxt.charAt(i); // needs to be an HTML entity if (code > 255) { // normally we encounter the High surrogate first if (0xD800 <= code && code <= 0xDBFF) { hi = code; lo = srcTxt.charCodeAt(i+1); // the next line will bend your mind a bit code = ((hi - 0xD800) * 0x400) + (lo - 0xDC00) + 0x10000; i++; // we already got low surrogate, so don't grab it again } // what happens if we get the low surrogate first? else if (0xDC00 <= code && code <= 0xDFFF) { hi = srcTxt.charCodeAt(i-1); lo = code; code = ((hi - 0xD800) * 0x400) + (lo - 0xDC00) + 0x10000; } // wrap it up as Hex entity c = "" + code.toString(16).toUpperCase() + ";"; } else { c = rawChar; } entTxt += c; len++; } return entTxt; } var name_fieldvalue = encodeURIComponent(uni2ent(name_fieldvalue)); if (name_fieldvalue.length==0) { document.getElementById("txtHint").innerHTML=""; return; } xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Your browser does not support XMLHTTP!"); return; } var url="ajax_namechange.php"; purl="name_fieldvalue="+name_fieldvalue; purl=purl+"&name_fieldname="+name_fieldname; purl=purl+"&id_val="+id_val; purl=purl+"&id_fieldname="+id_fieldname; purl=purl+"&table_name="+table_name; xmlhttp.onreadystatechange=stateChanged; xmlhttp.open("GET",url,true); xmlhttp.send(purl); } function stateChanged() { if (xmlhttp.readyState==4) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } Link to comment https://forums.phpfreaks.com/topic/201124-unicode-display-problem-when-updating-the-value-through-ajax/#findComment-1055207 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.