Как позвонить имя с помощью AJAX?

Я новичок в AJAX. Я хочу получить имя из базы данных в соответствии с onkey up, но я получаю эту ошибку в консоли «Недопустимая левая сторона в назначении». и когда я набираю его показ «функция показанного не определена».
Это мой код

Поиск:

This is myscript
function showname(d) {
var xhttp;
if (window.XMLHttpRequest) {
xhttp= new XMLHttpRequest();
}else{
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("demo").innerHTML = xhttp.responseText;
}
};
xhttp.open("POST", "ajax2.php?name"=+d, true);
xhttp.send();
}
this ajax2.php code

$name = $_GET["name"];
$db = new mysqli("localhost", "root", "", "customername");
$conn = $db->query("select customerName from customers like '".$name."%'");
$fetch = $conn->fetch_array();

?>
<?php foreach ($fetch as $key => $value) :?>
<p><?php echo $value ?></p>
<?php endforeach; ?>

Заранее спасибо.

0

Решение

xhttp.open («POST», «ajax2.php? name» = + d, true);

Я думаю, что у вас есть опечатка, вставьте = в кавычки.

xhttp.open("POST", "ajax2.php?name=" + d, true);
1

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector