Answer the question
In order to leave comments, you need to log in
PHP and AJAX issue. How to change value in AJAX using PHP?
There is a test script created in AJAX and PHP so that the page does not reload. In AJAX we have the following code:
function send() {
var text = $('...').val()
$.ajax({
type: "POST",
url: "...",
data: "...="+text,
success: function(html) {
$("...").empty();
$("...").append(html);
}
});
}
var text = $('...').val()
function send() {
var text = $('input_1').val()
$.ajax({
type: "POST",
url: "test.php",
data: "answer="+text,
success: function(html) {
$("text").empty();
$("text").append(html);
}
});
}
function send() {
var text = $('input_2').val()
$.ajax({
type: "POST",
url: "test.php",
data: "answer="+text,
success: function(html) {
$("text").empty();
$("text").append(html);
}
});
}
var text = $('...').val()
Answer the question
In order to leave comments, you need to log in
return json with response and variable name
var inputName = '<?=$phpVar?>';
function send() {
$.post(
"test.php",
{answer: $('input[name="'+inputName+'"]').val()},
function (json) {
$(".text").html(json.text);
inputName = json.inputName;
}
);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question