Jump to content

encoding problem


farucse

Recommended Posts

Dear Sir,

 

i am facing a  problem with ajax and php .

my php and ajax code :

 

1. file1.php

<?php
header('Content-Type: text/html; charset=utf-8');
?>
<?php
echo "<form  name='form1'>
Plate No:<input type='text' name='plate_no1' size = 1 maxlength =1>
<input type='text' name='plate_no2' size = 1 maxlength =1>
<input type='text' name='plate_no3' size = 1 maxlength =1>
<input type='text' name='plate_no4' size = 1 maxlength =1>
<input type='text' name='plate_no5' size = 1 maxlength =1>
<input type='text' name='plate_no6' size = 1 maxlength =1>
<input type='text' name='plate_no7' size = 1 maxlength =1>

<input type='button' name = 'save' id='save' value='Save Data' onclick='SaveData();'>";
?>

2. savedata.php

<?php
header('Content-Type: text/html; charset=utf-8'); 
?>
<?php
$plate_no = $_GET['plate_no1']." ".$_GET['plate_no2']." ".$_GET['plate_no3']." ".$_GET['plate_no4']." ".$_GET['plate_no5']." ".$_GET['plate_no6']." ".$_GET['plate_no7'];

echo $plate_no;

?>

 

3.file3.js

function SavaData() {
var plate_no1 = document.form1.plate_no1.value;
var plate_no2 = document.form1.plate_no2.value;
var plate_no3 = document.form1.plate_no3.value;
var plate_no4 = document.form1.plate_no4.value;
var plate_no5 = document.form1.plate_no5.value;
var plate_no6 = document.form1.plate_no6.value;
var plate_no7 = document.form1.plate_no7.value;

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="save_policy.php"
url=url+"?plate_no1="+plate_no1+ "&plate_no2="+plate_no2+ "&plate_no3="+plate_no3+ "&plate_no4="+plate_no4+ "&plate_no5="+plate_no5+ "&plate_no6="+plate_no6+ "&plate_no7="+plate_no7   
url=url+"&sid="+Math.random();
soapRequestStr='<?xml version="1.0" encoding="utf-8"?>';
xmlHttp.onreadystatechange=stateChanged; 
xmlHttp.open('GET',url,true);
//xmlHttp.open("GET",url,true);
xmlHttp.setRequestHeader('Content-type', 'text/xml;charset=utf-8');
xmlHttp.setRequestHeader('Content-length',soapRequestStr.length);
xmlHttp.setRequestHeader('soapRequestStr', 'close');
xmlHttp.send(soapRequestStr);

//xmlHttp.send(null)
}
function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
document.getElementById("txtHint2").innerHTML=xmlHttp.responseText 
} 
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
}
return xmlHttp;
}	

}

e.g.

if i send 9 2 3ص ص ص then i get the out pt from file2.php as  9 2 3  � �tml>

 

if i set POST method in ajax and  modify the varaible of file2.php with $_POST['']  then i get notice with alll of variable undefined..

 

So. please can you tell me where is my error or how can i solve this?

Please reply .

Thanks in Advance.

Regards,

Faruk Chowdhury.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.