[英]What is the easiest way to get an echoed or returned string from php into jquery/ajax
Let's say that I have in my test.php:假设我在 test.php 中有:
echo 'Hello, world'
And I want to place that text in a div.我想将该文本放在一个 div 中。
This doesn't work for me and the alert also does not pop out.这对我不起作用,警报也不会弹出。
$.ajax({
type: "GET",
url: "test.php",
data : data,
success: function(msg){
alert('Does it Work?');
("#div_1").html(message);
});
You have a syntax error, that may be the issue (you forgot to close a curly bracket and a parenthesis).您有语法错误,这可能是问题所在(您忘记关闭大括号和括号)。 Try尝试
$.ajax({
type: "GET",
url: "test.php",
data : data,
success: function(msg){
alert('Does it Work?');
$("#div_1").html(message.txt);
}
});
$.get('test.php',function(data) { alert('data:'+data); });
$.ajax({
type: "GET",
url: "test.php",
data : data,
success: function(msg){
alert(msg);
$("#div_1").html(msg);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.