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?
某草草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
滿天的星座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
習慣沉默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>