作者TonyQ (沉默是金。)
看板Ajax
标题Re: [ js ] 列出所有的hidden值
时间Thu Mar 18 16:31:25 2010
※ 引述《knives ()》之铭言:
: 因为我的input type="hidden" 里面的栏位是会变更
: 但是我希望我的ajax在传送参数的时候可以把所有的hidden变数都传出去
: 我的ajax是这样写的
: var data_str = '';
: var record= jQuery.ajax({
: url: "source/xxx.php",
: data:data_str,
: type: "POST",
: data:data_str,
: complete:load_complete(uid),
: async: false
: }).responseText;
: 我希望
: data_str 可以用 jQuery.each('阵列',function(key,value){
: data_str += key+'='+value
: }
: 可是里面的阵列我要怎麽取得,我现在选择器是这样写
: jQuery('#form_1'>input:hidden');
: 但是把data_str印出来却是
: 0=[object HTMLInputElement]1=[object HTMLInputEleme]
: 请问我该怎麽办
functon load_complete(){
var ret=[];
$("#form_1 >input:hidden").each(function(){
ret.push(this.name+"="+this.value);
//看需要决定要不要作url escape
});
return ret.join("&");
}
类似这样吧,印出来会有object是因为他是object,
这时候取他的name、value来操作就是了
--
I am a person, and I am always thinking .
Thinking in love , Thinking in life ,
Thinking in why , Thinking in worth.
I can't believe any of what ,
I am just thinking then thinking ,
but worst of all , most of mine is thinking not actioning...
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.137.10.220