On 4/20/07, Rick Faircloth <[EMAIL PROTECTED]> wrote:

 So if JS is enabled, the script will run, appending

?isAjax=true to whatever page is specified if my

form's action page… correct?


Exactly. The one caveat is that the script assumes that the action URL
doesn't already contain any URL variables. This one solves that issue:

$(function() {
   var $exampleForm = $("#exampleForm");
   var oldAction = $exampleForm.attr("action");
   var newAction = oldAction + (oldAction.indexOf('?") >= 0 ?
"&isAjax=true" : "?isAjax=true");
   $exampleForm.attr("action", newAction);
});

This does everything my previous script did with the following addition:

If the form's action URL has a question mark (?) in it, that means that it
already has URL variables -- "isAjax" gets appended to the existing URL
variables in this case. If it doesn't, then the action URL doesn't contain
any URL variables -- "isAjax" is appended to the URL as its only URL
variable in this case.

--
Aaron Heimlich
Web Developer
[EMAIL PROTECTED]
http://aheimlich.freepgs.com

Reply via email to