Hello all i'm turning objects "on (adding the class .active) and off" on a html page with html objects, not forms. And on every click i want it to create an array of the items with the class .active but i can't seem to get any results?!
is this in the right direction?
var data = $('li.tagToggle.active').serializeArray();
// li id format is 'id_0001'
alert(data)
$.post("/scripts/php/process.php",{
'data[]': data,
funcName : 'tagResults',
tagResults : '1'
})
keeps alerting and empty window but when i use this on a form it grabs all the objects with the class .active
any pointers welcome!
Definition and Usage. The 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.
Definition and Usage The serialize() function converts a storable representation of a value. To serialize data means to convert a value to a sequence of bits, so that it can be stored in a file, a memory buffer, or transmitted across a network.
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() .
You can serialize all inputs inside an element like this:
var data = $('YourId :input').serialize()
This is what I'm using
(function($){
$.fn.serializeAny = function() {
var ret = [];
$.each( $(this).find(':input'), function() {
ret.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( $(this).val() ) );
});
return ret.join("&").replace(/%20/g, "+");
}
})(jQuery);
to use it in your case $('li.tagToggle.active').serializeAny();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With