私は持っています
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);
...
...
と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);
}
?>
SQL条件を削除すると、javascriptはテーブルを表示し、matrkifとmark$ _post
上記のようにphpを離れると、テーブルが表示されません。
phpページの何が問題になっていますか?
これがjavascriptajax関数全体です。
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);
}
とても混乱しているので、コードを変更するのを手伝ってください。コードをもう一度書く必要がありますか?このコードは変更できますか?