欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JS的Ajax與后端交互數(shù)據(jù)的實(shí)例

 更新時(shí)間:2018年08月08日 09:27:32   作者:kerryqpw  
今天小編就為大家分享一篇JS的Ajax與后端交互數(shù)據(jù)的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

JS中很多地方會(huì)使用Ajax與后臺(tái)進(jìn)行數(shù)據(jù)交互。

Ajax是通過(guò)http,使得JS與后端進(jìn)行數(shù)據(jù)通信,由于Ajax的異步特性,可以使多個(gè)Ajax請(qǐng)求同時(shí)訪問(wèn)后端,對(duì)頁(yè)面的局部數(shù)據(jù)進(jìn)行邏輯處理,并渲染。

ajax中前端和后端的交互圖:

代碼實(shí)現(xiàn):

$.ajax({
    type: "post",
    url: "http://localhost:8080/ccnb/user/login",
    data: {
     "telephone": login_name,
     "password": login_password
    },
    dataType: "json",
//   contentType:'application/json',
    success: function (data) {
     alert(data.Flag);
     alert(data.Msg);
 
     }
 
    },
    error: function (XMLHttpRequest, textStatus, errorThrown) {
     alert(XMLHttpRequest.status);
     alert(XMLHttpRequest.readyState);
     alert(textStatus);
    },
   });

以上這篇JS的Ajax與后端交互數(shù)據(jù)的實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論