php - issue updating html after ajax response received -


after having multiple issues requesting data server posted this question. never got code work ended rewriting whole ajax request , i'm able insert data in database.

however, issue i'm having responsetext being sent ajax request not updating html.

at end of registration script, after values have been inserted database, have code tests make sure registration email has been sent user , sends string ajax request:

if (mail($to, $subject, $message, $headers)) {     echo "email_success";     exit; } else {     echo "email_failure";     exit; } 

once response has been received have condition test string has been returned:

hr.onreadystatechange = function() {     if (hr.readystate == 4 && hr.status == 200) {         if (hr.responsetext == "email_success") {              window.scrollto(0,0);              gebi("signupform").innerhtml = "<p>sign successful. check email activate account.</p>";         } else {              gebi("status").innerhtml = hr.responsetext;              gebi("signupbtn").style.display = "block";         }     } } 

the issue i'm have "signup_success" string not being recognised true , instead fires else statement.

what doing wrong?

probably error have trim response text before comparation.

trim code:

if (!string.prototype.trim) {   string.prototype.trim = function () {     return this.replace(/^\s+|\s+$/g, '');   }; } 

and then

hr.onreadystatechange = function() {     if (hr.readystate == 4 && hr.status == 200) {         var responsetext = hr.responsetext.trim();         if (responsetext == "email_success") {              window.scrollto(0,0);              gebi("signupform").innerhtml = "<p>sign successful. check email activate account.</p>";         } else {              gebi("status").innerhtml = hr.responsetext;              gebi("signupbtn").style.display = "block";         }     } } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -