I'm not quite sure what you're trying to say here.
AJAX in and of itself doesn't support anything. It's just a design pattern that encompasses many technologies. If you are using Client-Side and Server-Side languages you are familiar with nothing changes. The only thing that changes when using AJAX is how requests are made to your server.
iso-8859-1 is english. you will need to look up what the character set for Arabic is and simply replace the iso-8859-1 with the new value that will tell the browser to expect the new character set and display it accordingly. this goes for all language types outside of normal browser expectations (chinese, japanese...)
Welcome to the forums, maqsoodamd. Please note that the thread you posted on is over a year old and by a person who never came back to the forum. It is possible that you will not see a reply. Whenever you have a problem, please create a new thread and explain your problem in detail. Thanks!
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Dear All,
Since I was having trouble with AJAX charset encoding today in the morning with refresh mind I found the solution, the reason why I am posting here is , I searched 2 whole days to find a solution from forums, etc but I could not. however now I am lucky to find the solution for any language just using utf-8 first let mi write my ajax
My Ajax code is like below:
not:you can save below code to a page like ajax_post.js
Code:
var xmlhttp_sp = false;
try {
//If the Javascript version is greater than 5.
xmlhttp_sp = new ActiveXObject(”Msxml2.XMLHTTP”);
} catch (e) {
//If not, then use the older active x object.
try {
xmlhttp_sp = new ActiveXObject(”Microsoft.XMLHTTP”);
} catch (E) {
//Else we must be using a non-IE browser.
xmlhttp_sp = false;
}
}
if (!xmlhttp_sp && typeof XMLHttpRequest != ‘undefined’) {
xmlhttp_sp = new XMLHttpRequest();
}
function makerequest_sp(serverPage, params, objID)
{
var myRandom=parseInt(Math.random()*99999999);
params+=’&’+myRandom;
var url = serverPage;
//var params = “lorem=ipsum&name=binny”;
xmlhttp_sp.open(”POST”, url, true);
//Send the proper header information along with the request
xmlhttp_sp.setRequestHeader(”Content-type”, “application/x-www-form-urlencoded; charset=UTF-8″);
xmlhttp_sp.setRequestHeader(”Content-length”, params.length);
xmlhttp_sp.setRequestHeader(”Connection”, “close”);
xmlhttp_sp.onreadystatechange = function() {//Call a function when the state changes.
if(xmlhttp_sp.readyState == 4 && xmlhttp_sp.status == 200) {
document.getElementById(objID).innerHTML = xmlhttp_sp.responseText;
//alert(xmlhttp_sp.responseText);
}
}
xmlhttp_sp.send(params);
//xmlhttp_sp.send(null);
}
before I was using AJAX with GET method but when I GET form values in my language (farsi Afghanistan) it was just ???? and after using above ajax code I solved my problem.
Code:
//some comments
function makerequest_sp(serverPage, params, objID)
when you wanna call makerequest_sp it takes 3 params
1.serverPage like test.php
2.params the values of a form like name=nasir&id=34& …
3.objID is div id where you want to show xmlhttp_sp.responseText inside a div.
how you call this let me write a function how did I call
Code:
function test_dari(formid)
{
var formvalues = do_it(formid);
//this do_it function will retrieve all form name with its value
url=’test.php’;
var params=formvalues+’action=getform&’
makerequest_sp(url, params, ‘mytest’); //here is ajax call function
}
Bookmarks