科尔多瓦开发
AJAX stands for Asynchronous Javascript And XML. It is a client-side script used in Javascript to communicate with server to exchange data or anything without refreshing the page.
AJAX代表异步Javascript和XML 。 它是Java脚本中用于与服务器通信以交换数据或任何内容而无需刷新页面的客户端脚本。
Let us suppose we want to make a dynamic cordova based application where user needs to exchange data with server, say login credential verification, so we can use AJAX to send the data to the server and through the same gateway server, send the result back to the user.
让我们假设我们要创建一个基于动态Cordova的应用程序,其中用户需要与服务器交换数据,例如登录凭据验证,因此我们可以使用AJAX将数据发送到服务器并通过同一网关服务器,然后将结果发送回用户。
Ajax basic code: We will use jquery.
Ajax基本代码:我们将使用jquery。
$.ajax
is a jQuery function to make http POST, GET etc request to the server and receive results without the page being refreshed or reloaded.
$.ajax
是一个jQuery函数,用于向服务器发出http POST , GET等请求并接收结果,而无需刷新或重新加载页面。
$.ajax({
type : 'get', //Request method: GET, POST
url : 'http://studytonight.php/login.php', //Where to send the data
data: {name, password}, //What data you want to send
success:function(data) {
//Here you will receive data from server
//Do what you want to do with data
console.log(data) //This is a example, like we want to print the result
}
})
NOTE: Covering Ajax and jQuery is not in the scope of this tutorial. But we strongly advice you to learn abour Ajax, as it is very useful if you want to create dynamic Apps.
注意:涵盖Ajax和jQuery不在本教程的范围内。 但是我们强烈建议您学习Abour Ajax,因为如果您要创建动态应用程序,这将非常有用。
翻译自: https://www.studytonight.com/apache-cordova/introduction-to-ajax
科尔多瓦开发