我这样做:
$.ajax({
type: 'GET',
url: this.href,
async: true,
data: $('form').first().serialize(),
beforeSend: function() {
$.blockUI({ message: 'Please wait ...' });
},
complete: function() {
$.unblockUI();
},
success: function(result) {
$("#grid").replaceWith($("#grid", result));
},
dataType: "text"
});
是否可以显示从表单中获取的查询字符串,以便用户可以存储链接?
感谢。
基督教
答案 0 :(得分:4)
当然,只需预先计算序列化形式:
var the_data = $('form').first().serialize();
$.ajax({
type : 'GET',
url : this.href,
async : true,
data : the_data,
beforeSend: function() {
$.blockUI({ message: 'Please wait ...' });
},
complete : function() {
$.unblockUI();
},
success : function(result) {
$("#grid").replaceWith($("#grid", result));
// Based on your comment, I am alerting `the data` to clarify
// the example. Obviously you'll want to display this on the page
// rather than using an alert.
alert(the_data);
},
dataType : "text"
});
答案 1 :(得分:0)
只需将$('form').first().serialize()
保存为变量。
var query = $('form').first().serialize();
$.ajax({
type: 'GET',
url: this.href,
data: query,
...
success: function(result){
//you can use query in here...
}
...
});