I have
enter code here
function ajaxFunction(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser is too old to run me!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
$.post('userfind.php', function(data) {
document.getElementById("myTable").style.display = "block";
var x=document.getElementById("myTable");
for (var i = 0; i < data.length; i++) {
var row=x.insertRow(-1);
var cell1=row.insertCell(-1);
var cell2=row.insertCell(-1);
...
...
and in php
enter code here
<?php
session_start();
$username = "XXXXXXXX";
$password = "XXXXXXXX";
$database = "XXXXXXXX";
$link = mysql_connect("localhost", "$username", "$password");
if(!$link) {echo("Failed to establish connection to mysql server");
exit();}
$status = mysql_select_db($database);
$oId = mysql_real_escape_string($_POST["order_IDsearch"]);
if (isset($order_IDsearch)){
$result = mysql_query ("SELECT * FROM personal_info WHERE order_id= '".$oId."' ");
$myjsons = array();
while($row = mysql_fetch_assoc($result)){
$myjsons[] = $row;
}
echo json_encode($myjsons);
}
?>
the javascript will show the table if i remove the SQL condition, matrk if and mark $_post
and it wont show the table if i leave the php as you see above,
whats wrong with the php page help please
here is the whole javascript ajax function,
enter code here
function ajaxFunction(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser is too old to run me!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
$.post('userfind.php', {orderId:"order_IDsearch"}, function(data) {
var obj = $("#myTable").show();
var x = obj.get(0);
for (var i = 0; i < data.length; i++) {
var row=x.insertRow(-1);
var cell1=row.insertCell(-1);
...
...
cell1.innerHTML = "<b><input name='edit' type='button' onClick='editRow(this)' value='Edit' /> <input name='del' type='button' onClick='delRow(this)' value='Del' /></b>";
cell2.innerHTML = data[i].user_id;
cell3.innerHTML = data[i].first_name ;
....
....
}},'json');}
}
ajaxRequest.open("POST", "userfind.php", true);
ajaxRequest.send(null);
}
It’s so confusing me please help me to modify the code, should I write the code again? can this code be modified?
You are not passing anything to your php file from
$.post…make it like
This should work…
If your order_IDsearch is dynamic then have it done like this
And on PHP side you will have to access it in
To send multiple values