search

Home  >  Q&A  >  body text

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.

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?

大家讲道理大家讲道理2756 days ago563

reply all(4)I'll reply

  • 某草草

    某草草2017-05-18 10:57:34

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

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-18 10:57:34

    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

    reply
    0
  • 黄舟

    黄舟2017-05-18 10:57:34

    Just send it the way you received it

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-18 10:57:34

    $('#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>

    reply
    0
  • Cancelreply