• Jquery Ajax笔记


    $.ajax()返回底层创建的XMLHttoRequest对象.

    $.ajax({
               url: './mock-data.json',
    method: 'get',
    dataType: 'json',
    success: function(res) {
    console.log(res.data);
    for (var i = 0; i < res.data.length; i++) {
    str += '<li>' + res.data[i].name + '</li>';
    }
    $('ul').append(str);
    },
    error: function(err) {
    console.log(err);
    } })

    Get方法:

    $.get() 方法通过 HTTP GET 请求从服务器上请求数据

    $.get('./mock-data.json', function(res, status) {
    var result = JSON.parse(res);
    result = result.data;
    })

    Post方法:

    $.post() 方法通过 HTTP POST 请求向服务器提交数据

    $.post('./mock-data.json', {
    name: '111'
    }, function(res, status) {
    alert("数据: " + data + " 状态: " + status);
    })
  • 相关阅读:
    Python调用C++的DLL
    Go-map
    Go-切片
    Go-数组
    Go-流程控制
    Go-运算符
    Go-变量和常量
    Go-VS Code配置Go语言开发环境
    Go-跨平台编译
    Go-从零开始搭建Go语言开发环境
  • 原文地址:https://www.cnblogs.com/qingfengyuan/p/12980713.html
Copyright © 2020-2023  润新知