Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add data via $.ajax ( serialize() + extra data ) like this

Tags:

jquery

I want to add extra data after i use $('#myForm').serialize() + extra data

$.ajax({    type: 'POST',    url: $('#myForm').attr('action'),    data: $('#myForm').serialize(),   // I WANT TO ADD EXTRA DATA + SERIALIZE DATA    success: function(data){       alert(data);       $('.tampil_vr').text(data);    } }); 
like image 513
Joko Wandiro Avatar asked Dec 10 '10 06:12

Joko Wandiro


People also ask

How do you serialize form data?

jQuery serialize() MethodThe serialize() method creates a URL encoded text string by serializing form values. You can select one or more form elements (like input and/or text area), or the form element itself. The serialized values can be used in the URL query string when making an AJAX request.

What is data $( this serialize ()?

Data serialization is the process of converting an object into a stream of bytes to more easily save or transmit it. The reverse process—constructing a data structure or object from a series of bytes—is deserialization.

How do you serialize data in JavaScript?

In JavaScript, for example, you can serialize an object to a JSON string by calling the function JSON. stringify() . CSS values are serialized by calling the function CSSStyleDeclaration. getPropertyValue() .


1 Answers

What kind of data?

data: $('#myForm').serialize() + "&moredata=" + morevalue 

The "data" parameter is just a URL encoded string. You can append to it however you like. See the API here.

like image 132
jthompson Avatar answered Sep 17 '22 18:09

jthompson