通常当我想在一个PHP文件中创建新的内容和地方实现它在我的地盘我做这样的事情(JS和PHP):发送多个PHP文件与AJAX
case 'someCasename':
...
include_once 'file.php';
break;
...
success: function(data){
$("#idSelector").html(data);
}
和新内容显示在选定的元素上。
但我很好奇,如果它可能发送多个php文件在同一时间。不知道这是否真的有必要,而且我还没有碰到过需要这样做的单一时间,但我想到了这一点,并想问一问。这最后的代码是最有可能非常非常错误的,但我只是想展示我的意思:
case 'someCasename':
...
$phpArray = array("file1" => include_once 'file1.php', "file2" => include_once 'file2.php', "file3" => include_once 'file3.php'):
echo $phpArray;
break;
...
success: function(data){
$("#idSelector").html(data.file1);
$("#idSelector").html(data.file2);
$("#idSelector").html(data.file3);
}
是这样的,即使remotly可能吗?你不能json_encode php文件可以吗?
查看jQuery的load()方法。 http://api.jquery.com/load/ –