Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
295 views
in Technique[技术] by (71.8m points)

javascript - jQuery AJAX提交表单(jQuery AJAX submit form)

I have a form with name orderproductForm and an undefined number of inputs.(我有一个名称为orderproductForm的表单,输入的数量不确定。)

I want to do some kind of jQuery.get or ajax or anything like that that would call a page through Ajax, and send along all the inputs of the form orderproductForm .(我想做某种jQuery.get或ajax或类似的事情,它将通过Ajax调用页面,并发送所有形式为orderproductForm的输入。) I suppose one way would be to do something like(我想一种方法是做类似的事情) jQuery.get("myurl", {action : document.orderproductForm.action.value, cartproductid : document.orderproductForm.cartproductid.value, productid : document.orderproductForm.productid.value, ... However I do not know exactly all the form inputs.(但是我不完全知道所有的表格输入。) Is there a feature, function or something that would just send ALL the form inputs?(是否有仅发送所有表单输入的功能部件或功能?)   ask by Nathan H translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is a simple reference:(这是一个简单的参考:)

// this is the id of the form $("#idForm").submit(function(e) { e.preventDefault(); // avoid to execute the actual submit of the form. var form = $(this); var url = form.attr('action'); $.ajax({ type: "POST", url: url, data: form.serialize(), // serializes the form's elements. success: function(data) { alert(data); // show response from the php script. } }); }); I hope it helps you.(希望对您有帮助。)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...