Javascript Serializing Question
I'm using the following... // (jquery / pseudo code) var base = $('form[name='gs']').attr('action'); var params = $('form[name='gs']').serialize(); var url = base + '?' + param
Solution 1:
Declare global variables outside the function:
var globalBase, globalParams;
Then cache the values the initial time and update them accordingly:
globalBase = (globalBase === void(0)) ?
$('form[name="gs"]').attr('action') :
globalBase;
globalParams = (globalParams === void(0)) ?
$('form[name="gs"]').serialize() :
globalParams;
var url = globalBase + '?' + globalParams;
If you need to update the base or params based on what is typed on key press, then you can replace the else statements with something like $(yourInput).val()
.
Post a Comment for "Javascript Serializing Question"