ok so i have posted my code below. it is a basic function that takes the form as an argument. then it does a post to check if the email already exists in the database. then hits a callback function that sets the value of the global var dupsfound to either true or false. then after the post it returns true or false depending on the value of dupsfound.
problem is that when it gets to the alert(dupsfound) line, the alert spits out the default value of dupsfound. so it does not seem to be setting the value of dupsfound. var dupsfound="none"; function checkEmailDups(myemail) { $.post("checkemail.cfm", { email: myemail }, function(data){ if ($.trim(data) == "available") { dupsfound=false; } else if ($.trim(data) == "taken") { dupsfound=true; } }); alert(dupsfound); return false; if (dupsfound == true) { return true; } else if (dupsfound == false) { return false; } } Rob Desbois-2 wrote: > > That should work if errorsFound is global - can you provide your code or > give us a link to look at? > --rob > > On 7/19/07, bdee1 <[EMAIL PROTECTED]> wrote: >> >> >> >> i am building a function to validate a registration form for my site. >> one >> of >> the things i need to validate is that the email address entered into the >> form does not already exist in the database. >> >> in my formValidate function i perform several tests. if a test fails i >> increment a errorsFound variable. at the end of my function if >> errorsFound >> is greater than 0, i do not submit the form. >> >> the test for my email field does a $.post to a checkEmail - a page that >> checks the database for duplicate email addresses. then my callback >> function looks st the results of the post - if duplicates were found, i >> increment my errorsFound variable. >> >> problem is that from within my $.post callback function i cannot seem to >> access my errorsFound variable. >> >> how can i get my post callback function to increment my errorsFound >> variable? >> -- >> View this message in context: >> http://www.nabble.com/changing-the-value-of-a-global-variable-inside-an-post-callback-function--tf4111860s15494.html#a11691585 >> Sent from the JQuery mailing list archive at Nabble.com. >> >> > > > -- > Rob Desbois > Eml: [EMAIL PROTECTED] > Tel: 01452 760631 > Mob: 07946 705987 > "There's a whale there's a whale there's a whale fish" he cried, and the > whale was in full view. > ...Then ooh welcome. Ahhh. Ooh mug welcome. > > -- View this message in context: http://www.nabble.com/changing-the-value-of-a-global-variable-inside-an-post-callback-function--tf4111860s15494.html#a11693479 Sent from the JQuery mailing list archive at Nabble.com.