xmlhttp request problem
This is my JavaScript function for xmlhttp:
var params = "a=" + encodeURIComponent(a)
+ "&b=" + encodeURIComponent(b)
+ "&c=" + encodeURIComponent(c);
var url = "noob.php";
xmlHttp2.open("POST", url, true);<<<<up till here also no prob,did some testing
xmlHttp2.onreadystatechange = stateChanged2;
xmlHttp2.send(params);
}
This is noob.php
<?php
include('config.inc.php');
include('database.inc.php');
$a = mysql_real_escape_string($_POST['a'], $con);
$b = mysql_real_escape_string($_POST['b'], $con);
$c = mysql_real_escape_string($_POST['c'], $con);
mysql_query("INSERT INTO users (inchat,preference) values('N','$a$b$c');");
echo mysql_insert_id();
mysql_close($con);
?>
All the code of noob.php are working, I tried it with a html form. So the possibl开发者_运维百科e error should lie on:
xmlHttp2.onreadystatechange = stateChanged2;
xmlHttp2.send(params);
send parameter failed, I don't know how to test this
the string is sent is not recognised by noob.php (somehow - maybe cause the format sent is wrong?)
The problem is the parameter is not inserted into the table. So which of the possible choice above is true?
All the code of noob.php are working, I tried it with a html form. So the possible error should lie on:
xmlHttp2.onreadystatechange = stateChanged2;
xmlHttp2.send(params);
This kind of problems most times are easily identified by placing an alert after some suspicious line.
So before you have any doupts about xmlHttp2.send(params);
firstly place an alert after xmlHttp2.onreadystatechange = stateChanged2;
if the alert does not appear then go where the function stateChanged2;
is declared and investigate it again with an alert (most probably the prblem is in that function, there must be an error there);
精彩评论