怎样通过ajax提交数据

ajax的出现彻底改变了javascript命运,通过ajax可以直接向服务器提交数据,有两种方式:

get方式,数据直接拼接在地址中
post方式,数据由data字段携带

post方式,data中是参数。

    $.ajax({
        url:"http://localhost/contact2/user/list.do",
        type:"post",
        dataType:"json",
        data:"username=王&order=desc",
        success:function(data){
            alert("11");
        }

    });

get方式,数据在地址栏中:

    $.ajax({
        url:"http://localhost/contact2/user/list.do?username=zhangsan",
        type:"post",
        dataType:"json",
        success:function(data){
            alert("11");
        }

    });
原文地址:https://www.cnblogs.com/lenve/p/4518008.html