jQuery .get-如何显示.get请求的结果? [英] jQuery .get - how to display the result of the .get request?
本文介绍了jQuery .get-如何显示.get请求的结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在努力让jQuery .get
开始工作.
I'm TRYING to get jQuery .get
to work.
我有两个文件.
I.
我在.click
事件上执行此操作的地方:
I.
Where I'm perfoming this, on .click
event:
$.get("employee.php",
{ FirstName: substr[0], LastName: substr[1] },
function(data) {
// HOW DO DISPLAY THE RESPONSE in #div?
}
);
substr
来自:var substr = ( $(this).html() ).split('<span>')[0].split(' ');
II.
参数已成功传到employee.php
,并且萤火虫显示如下响应:
II.
Params are being successfuly past to employee.php
and firebug display the response like this:
<div class="employeePopUpBox">
GET isn't empty. John, Doe
</div>
PHP文件:
<div class="employeePopUpBox">
<?php
if(!empty($_GET)) {
$FistName = $_GET['FirstName'];
$LastName = $_GET['LastName'];
echo 'GET isn\'t empty. '.$FistName.', '.$LastName;
} else {
echo "GET is empty";
}
?>
问题是如何在div#response
中显示响应?
任何建议都将不胜感激.
The quastion is how to display the response inside div#response
?
Any suggestion are much appreciated.
推荐答案
只需使用常规的.html()
方法.
$.get("employee.php",
{ FirstName: substr[0], LastName: substr[1] },
function(data) {
$("div#response").html(data);
}
);
或改用一行一行
$("div#response").load("employee.php?FirstName="+substr[0]+"&LastName="+substr[1]);
这篇关于jQuery .get-如何显示.get请求的结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文