Answer the question
In order to leave comments, you need to log in
Why is there an empty response in the request to the DLE database?
Hello. Look at the code.
<a href="#" onclick="giveMeUsername('1');return false;">Показать имя пользователя</a>
function giveMeUsername(user_id) {
$.ajax({
type: "GET",
url: "/engine/ajax/givemeuser.php", // Имя файла к которому будет идти AJAX запрос
data: "user_id="+user_id, // ID юзера которого будем выбирать
success: function(data){
alert(data); // Итог: Алерт с Именем пользователя
}
});
}
<?php
define( 'DATALIFEENGINE', true );
define( 'ROOT_DIR', substr( dirname( __FILE__ ), 0, -12 ) );
define( 'ENGINE_DIR', ROOT_DIR . '/engine' );
require_once ENGINE_DIR . '/classes/mysql.php';
require_once ENGINE_DIR . '/data/dbconfig.php';
$user_id = intval($_GET['user_id']);
$USER = $db->super_query("SELECT * FROM " . USERPREFIX . "_users WHERE user_id='{$user_id}' ");
echo $USER['username'];
?>
Answer the question
In order to leave comments, you need to log in
From the manual, the data field is an object.
$.ajax({
method: "POST",
url: "some.php",
data: { name: "John", location: "Boston" }
})
.done(function( msg ) {
alert( "Data Saved: " + msg );
});
function giveMeUsername(user_id) {
$.ajax({
type: "GET",
url: "/engine/ajax/givemeuser.php?user_id="+user_id, // Имя файла к которому будет идти AJAX запрос
success: function(data){
alert(data); // Итог: Алерт с Именем пользователя
}
});
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question