serializing form doesn't update with listener
Hey guys, I'm wondering can someone help me out. I'm using javascript to serialize a search form. It's working.. however, if the user changes the query (backspacing, typing more, etc.) it doesnt update (I'm using a listener) and throws back undefined. How would fix this? http://pastebin.com/edVmQ3si
EDIT: Just to clarify, the listener is working. It's just getting undefined when looking for the values from the code I linked.
Listener just calls the function which executes the code l开发者_如何学Goinked.
Attach it to the keyup
event...
var searchInput = $('form[name="gs"]'),
searchForm = searchInput.closest('form'); // Thanks Matt Ball
var base = searchInput.attr('action');
searchInput.keyup(function() {
var params = searchForm.serialize();
var url = base + '?' + params;
// Do what you need with url.
});
精彩评论