S
S
Sergey2015-11-02 21:40:38
JavaScript
Sergey, 2015-11-02 21:40:38

How to send your data in js form without ajax?

There is a form submission handler code:

$('#kvm_vm_tab2 #form form').on('submit', function(e){
  e.preventDefault();
  var datastring = $(this).serialize();
  $.ajax({
            type: "GET",
            url: "index.php",
            data: datastring,
            dataType: "json",
        });
});


How can I change the code so that this datastring is passed in the form, but the data is sent via GET without Ajax, but by a regular submit? Those. so that the browser starts submitting the form as usual, but with my datastring? (just in the form new fields and values ​​that I changed using jquery, so it's important to send exactly my new datastring)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
petyagrill, 2015-11-02
@butteff

If you need to send a GET with a reload, you can add the necessary inputs to the form using jquery after processing the data, or send a GET using location.href after processing.
If you threw what is on jsfiddle.net and wrote step by step what should happen maybe you'll get an answer much faster

A
Adamos, 2015-11-02
@Adamos

Actually, this line prevents the data from leaving the site:
e.preventDefault();
Remove it and submit, which is the default, will happen after your function completes.
And if you need to send not the data that was entered into the form - create a new form, put an input with the new data into it and make it submit.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question