Answer the question
In order to leave comments, you need to log in
How to AJAX'om get information from the server?
JS
$.ajax({
method: "POST",
url: "/server.php",
data: {
user: user,
title: title
},
success: function(msg){$('div.AddCoreResult').html(msg);}
});
echo "<h1 class='SystemGood'>Успешно</h1>";
<h1 class='SystemGood'>Успешно</h1>
" from the server with Ajax and display it on the page in case of a successful request? div.AddCoreResult
<div class="AddCoreResult"></div>
only <h1 class='SystemGood'>Успешно</h1>
the entire page should be displayed in this block
Answer the question
In order to leave comments, you need to log in
In general, the correct format for communication between JS and Php is JSON. You'd better write something like
A on the js side justecho json_encode(['msg' => 'Успешно']);
$.ajax({
method: "POST",
url: "/server.php",
data: {
user: user,
title: title
},
success: function(msg){$('div.AddCoreResult').html("<h1 class='SystemGood'>"+msg.msg+"</h1>");}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question