-3
是否有可能讓jQuery的Ajax響應到多個DIV?是否可以將ajax響應分發給多個div?
我想分發不同的DIV中的迴應。
HTML
<div id="postrequest1"></div>
<div id="postrequest2"></div>
JQ
$(document).ready(function() {
$("#loaddata").click(function(){
$.post("php/test2.php",
{ name:$("#txtinput").val(),
location:$("#txtlocation").val() },
function(response) {
$("#postrequest").html(response);
});
});
});
pH值:
$post_name=$_POST["name"];
$post_location=$_POST["location"];
if($post_name && $post_location){
echo "Name: ". $post_name; // this should be displayed in postrequest1
echo "Location: " .$post_location; // this should be displayed in postrequest2
}
您可以將響應放在任意數量的div中。有什麼問題 ? – SSA 2014-10-01 13:43:04
我認爲問題是將php輸出分成兩部分。 – 2014-10-01 13:46:37
^^你說得對。 – SSA 2014-10-01 13:47:20