2013-07-24 164 views
0

JavaScript中是否存在一种方法来加载页面而不实际显示该页面?在javascript中加载页面

我想加载一个php页面,它将处理数据库插入任务。

+1

一些文档https://developer.mozilla.org/en-US/docs/AJAX – wwww

回答

1

是有,你可以使用XMLHttpRequest这一点。

这里是一个例子

function done() { 
    console.log(this.responseText); // The response from the server 
}; 

var XHR = new XMLHttpRequest(); 

XHR.onload = done; // Set the onload function 
XHR.open("get", "something.php", true); // Type & File 
XHR.send(); // Send the request 

下面是对MDN XMLHttpRequest