Javascript 通过$.ajax GET发送jQuery$.data对象
我有一个表单,有一堆输入字段。我想对所有字段发出一个ajax GET请求!迄今为止最简单的方法是将输入分配给数据对象:Javascript 通过$.ajax GET发送jQuery$.data对象,javascript,php,jquery,ajax,Javascript,Php,Jquery,Ajax,我有一个表单,有一堆输入字段。我想对所有字段发出一个ajax GET请求!迄今为止最简单的方法是将输入分配给数据对象: $('#myForm').find('input').each(function(index){ myData = $.data($('#myForm'), $(this).attr('name'), $j(this).val()); }); …然后通过ajax泵送: $.ajax({ type:"GET", url: '/otherpage.php
$('#myForm').find('input').each(function(index){
myData = $.data($('#myForm'), $(this).attr('name'), $j(this).val());
});
…然后通过ajax泵送:
$.ajax({
type:"GET",
url: '/otherpage.php',
data = myData,
error(function(){}),
success(function(){});
});
但这当然不起作用。。。otherpage.php中没有显示$\u GET变量,控制台显示myData
是一个巨大的对象处理
如何像这样通过ajax发送数据?有更好的办法吗 使用jQuery
serialize()代码>方法:
$.ajax({
type:"GET",
url: '/otherpage.php',
data = $('#myForm').serialize(),
error(function(){}),
success(function(){});
});
希望它能帮助你。就这么简单,是吗?真不敢相信我没有发现。。。谢谢男人:)没问题,很高兴它有帮助!将答案标记为已接受,以便其他人在遇到相同问题时可以找到解决方案:)
$.ajax({
type:"GET",
url: '/otherpage.php',
data = $('#myForm').serialize(),
error(function(){}),
success(function(){});
});