hi guys...iam a new member nd im new to ajax nd php... iam trying to update my database through ajax. the problem is that when i m passing parameters to the update file it only pass the id not the edited text. its in a textarea. here is some code: database name is backend.
// JavaScript Documentvar xmlhttp
function updatedata(id)
{
var xmlhttp
xmlhttp= GetXmlHttpObject()
if(xmlhttp==null)
{
alert("browser does not support HTTP request")
return
}
xmlhttp.onreadystatechange= function()
{
if(xmlhttp.readystate==4)
{
var updt= document.getElementById("mydata");
updt.value=xmlhttp.responseText;
}
}
var str= document.getElementById("mydata").value;
var url="insert.php?id=" + id + "&data=" + str;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
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;
}
Do please read the posting guidelines regarding silly thread titles. The thread title is supposed to help people who have a similar problem in future. Yours is useless for this purpose. You can (and should) edit it to make it more meaningful.
Also please read the posting guidelines regarding [code] tags.
there is no problem with the db query. when i alert the url in the js file it show me like this:
insert.php?id=1&data=these online lectures have attracted people of all ages.It offers purely education courses which are online especially designed for kids and children although these online lectures have attracted people of all ages. while when i use to echo the id on insert.php it shows nothing and similarly the id is not in the url.
if you have FireFox with the FireBug add-on installed, you can check, what has been submitted in the AJAX call. on the other hand, if insert.php echoes out anything, it should be present in the return data (also available in FireBug)
the ajax call submits both the id and the content but at the insert.php page i could only see the content in the url not the id thats y the database never updates..i echoed the content in the insert.php page it shows it but the problem is about the id??
var_dump($_GET) showed this:
array(3) { ["mydata"]=> string(366) " Sabia Technologies is a part of Bir Al Sabia Group Of Companies achieved recognition with high quality web development projects and delivering web development services of any complexity to clients worldwide. Our customers are companies of all sizes ranging from start ups to large enterprises who realize that they need a professional internet solution to generate." ["x"]=> string(2) "14" ["y"]=> string(1) "8" }
ok then tell me what should i do to make it correct? i am new to all of this stuff so be a little explanatory plz...if u can show it to me in the code then it will be more easy to me
hey dormilich! its working now but now the problem is that when i click the save button the record is updated but when i veiw the record it shows me the older one not the updated record while when i look at the database its updated there.... and when i use to delete the offline files in the internet options then for one instance it shows me the updated record but after that the same goes on.... wats the problem?