javascript - jquery ajax requests backend data. How to send it to the backend after modification? Can anyone please explain the general process? It would be better if there is an example. Please.
大家讲道理
大家讲道理 2017-05-18 10:55:34
0
4
553

The data is obtained using ajax through the interface provided by the background. How to transfer it to the background after the page is modified?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(4)
某草草

The background gives you a query interface, and it must also provide a submission interface, and then use ajax to request it

滿天的星座

Call the background interface through get or post to get the data. The data is usually a json string object. Convert it into a json object that can be compiled by js. Use the method in the json object in js instead of using eval to parse and assign the data to your Then operate the page to change the page data. Afterwards, these changed data will be obtained and converted into data and sent to the background. As for whether the background requires string or object format, it depends on the background needs

黄舟

Just send it the way you received it

習慣沉默
$('#get').click(function() {
    $.get(
        "/example/jquery/demo_test.asp",    // 后台请求数据地址
        function(data,status){
          // 将你请求进行相应处理
    });
}); 
      
$('#post').click(function() {
    $.post("/example/jquery/demo_test_post.asp",  // 后台请求数据地址
        {
          name: $('.firstname').val(),
          city: $('.lastname').val()
        },
        function(data,status){
          alert("数据:" + data + "\n状态:" + status);
    }); 
}); 
<form>
    First name:<input type="text" class="firstname">
    Last name:<input type="text" class="lastname">
</form>
<button id = 'get'>获取</button>
<button id = 'post'>发送</button>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template