Ajax请求地址拼接参数

param() 方法创建数组或对象的序列化表示形式。

var urldemo = {
     
	firstname:"John",
	lastname:"Doe",
	age:"50",
	eyecolor:"blue",
}
$.ajax({
     
    url: "http://www.*****?"+$.param(urldemo),
     headers: {
     
         "content-type": "application/x-www-form-urlencoded",
         "withCredentials ":"true"
     },
     data: data,
     type: 'POST',
     success: function (res) {
     
         
     },
     error:function(err){
     
         
     }
});

你可能感兴趣的:(Javascript)