是更好地做這樣的事情:PHP文件加載與HTML與AJAX?
//PHP FILE:
<html>
<body>
hi
<?php
//load first 50 comments from mysql
?>
</body>
</html>
或者這樣:
//HTML FILE
<html>
<body>
hi
<div id="hello">
</body>
</html>
//JS file:
$(document).load(function() { //or whatever it is if not 'load', I can figure it out
$.ajax(/*php call, receive JSON of the mysql data*/);
});
我要找的速度和空間效率。哪個更好 - 讓PHP文件發送整個HTML文件,還是讓HTML文件以JSON格式發送數據?
在此先感謝。
衡量它。充其量,你可以得到自以爲是的答案。速度和效率 - 範圍太廣泛。 –