标签:stat .text for 请求 urlencode ext form序列化 success json
1.form序列化ajax$.ajax({
url: "/add_host_ajax",
type: ‘POST‘,
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
data: $("#add_form").serialize(),
success: function (data) {
var obj = JSON.parse(data);
if (obj.status) {
location.reload();
} else {
$(‘#erro_msg2‘).text(obj.error);
}
}
})
2.拼接url的ajax
$.ajax({
url: "/add_host_ajax?hostname="+hostname1111,
type: ‘POST‘,
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
data: $("#add_form").serialize(),
success: function (data) {
var obj = JSON.parse(data);
if (obj.status) {
location.reload();
} else {
$(‘#erro_msg2‘).text(obj.error);
}
}
})
3.拼data的ajax
$.ajax({
url: "/add_host_ajax?hostname="+hostname1111,
type: ‘POST‘,
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
data: ‘hostname=‘+hostname1111,
success: function (data) {
var obj = JSON.parse(data);
if (obj.status) {
location.reload();
} else {
$(‘#erro_msg2‘).text(obj.error);
}
}
})
标签:stat .text for 请求 urlencode ext form序列化 success json
原文地址:http://blog.51cto.com/13522822/2129161