jQuery AJAX submit form

0 votes

I have with me a form with the name orderproductForm and an undefined number of inputs.

I would like to use some kind of  jQuery.get or ajax or anything like that which can call a page through Ajax, and send it along with all the inputs of the form orderproductForm.

I suppose one way would be to do something on the lines of the code mentioned below:-

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 and is there a feature, function or something that would just send all the form inputs?

Feb 8 in Java by Rahul
• 8,980 points
76 views

1 answer to this question.

0 votes

There is a simple input mentioned below which could be of your help:

// 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 actionUrl = form.attr('action'); 
$.ajax({ 

type: "POST", 
url: actionUrl, 
data: form.serialize(), // serializes the form's elements. 
success: function(data) 
{ 
  alert(data); // show response from the php script. 
    } 
  });
});
answered Feb 8 by Soham
• 8,730 points

Related Questions In Java

0 votes
2 answers

How can I invoke a method when the method name is in the form of a given string?

You could probably use method invocation from reflection: Class<?> ...READ MORE

answered Aug 19, 2019 in Java by Sirajul
• 59,170 points
1,015 views
0 votes
1 answer

Use Servlets with Ajax

Here, we are going to create the ...READ MORE

answered Jul 16, 2018 in Java by Akrati
• 3,170 points
2,618 views
0 votes
1 answer

Evaluating a math expression given in string form

import javax.script.ScriptEngineManager; import javax.script.ScriptEngine; import javax.script.ScriptException; public class Test { ...READ MORE

answered Oct 12, 2018 in Java by Daisy
• 8,120 points
4,615 views
0 votes
1 answer

how to read csv file form sftp connection and store into string object in java code and convert into json.....post it using rest api

Hey, @Pooja, Before starting with anything you should ...READ MORE

answered May 13, 2020 in Java by Roshni
• 10,500 points
1,999 views
0 votes
1 answer

What are XMLHttpRequest Object in Ajax?

 As, you are up to ajax so ...READ MORE

answered Jan 31, 2020 in Java-Script by Niroj
• 82,680 points
393 views
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,510 points
284 views
0 votes
1 answer

Uncaught TypeError: Cannot read property 'msie' of undefined - jQuery tools

Hello, Use the following script tag in your ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,680 points
7,911 views
0 votes
1 answer

Uncaught Error: Bootstrap's JavaScript requires jQuery

Hello @kartik, You have provided wrong order for ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,680 points
14,540 views
0 votes
1 answer

jQuery get value of select onChange

Try the following lines of code- $('select').on('change', function() ...READ MORE

answered Feb 11 in Java by Soham
• 8,730 points
42 views
0 votes
1 answer

jQuery UI " $("#datepicker").datepicker is not a function"

I struggled with a similar problem for ...READ MORE

answered Feb 17 in Java by Soham
• 8,730 points
469 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP