Author Topic: AJAX & JQuery - Problem  (Read 158 times)

0 Members and 1 Guest are viewing this topic.

Offline havenpetsTopic starter

  • Irregular
    • View Profile
AJAX & JQuery - Problem
« on: May 20, 2010, 07:28:13 PM »
Code: [Select]
function check_form(){
httpObject.onreadystatechange = function() {
if(httpObject.readyState == 4){
run_ajax(httpObject.responseText);
    }
}
}

function run_ajax(solution){
if(solution == 0){
$("#"+formtype).addClass('ui-state-error');
updateTips("This "+formtype+" already exists in our database.");
return false;
}else{
return true;
}
}
(later in coding)
Code: [Select]
function (){
var bValid = true;
bValid = bValid && check_form("username");
if(bValid){
alert("SUCCESS");
}

(I took out all the unnecessary coding. The problem lies with it not saying success even though it is! When I alert bValid before the if(), it says "undefined". Anyone know a way around this?
« Last Edit: May 20, 2010, 07:33:22 PM by havenpets »

Offline thorpe

  • Administrator
  • 'Mind Boggling!'
  • *
    • View Profile
Re: AJAX & JQuery - Problem
« Reply #1 on: May 20, 2010, 08:04:40 PM »
Why aren't you using jQuery's Ajax implementation? It will make your life much easier and your code code much more stable / easier to maintain.

PHP Freaks Forums

« on: »

Tired of these ads? Purchase a supporter subscription to get rid of them.