Welcome Guest, Not a member yet? Register   Sign In
Ajax msg display help!
#1

[eluser]debow[/eluser]
Hello, I have the following ajax setup for a registration form and its works for the most part but what I'm trying to clean up is the message on any alert or success that keeps showing the alert plus all code in the same popup. Is there anyway around this? How do I get only the error or success message.

AJAX
Code:
$(document).ready(function() {
     $('#registration_form').submit(function(){
            var userEmail =$('#userEmail').val();
            var userPassword =$('#userPassword').val();            
            if(!userEmail || userEmail == '')
            {
              alert('Please enter a valid email address');
              
              return false;
            }
            if(!userPassword || userPassword == '')
              {
                alert('You must choose a password');
                return false;
              }              
            var form_data = {
                  userEmail: $('#userEmail').val(),
                  userPassword: $('#userPassword').val(),
                  //ajax: '1'  
                };
            $.ajax({
                url: "<?php echo site_url('users/add'); ?>",
                type: 'POST',
                data: form_data,
                success: function(msg) {
                    alert(msg);
                }
              });
      return false;
       });    
});

For the email/password empty filed check it works but when my post is ran my controller does the following

Code:
if ($_POST)
       {
                if ($this->form_validation->run() === TRUE)
                {  
                      $userId = $this->user_model->AddUser($_POST);
                    echo "Registration Successful";
                }
                else
                {
                    echo validation_errors(' ',' ');
                }
        }

My issue is with this message. I only want to see "Registration Successful" not all the html code as well. Attached is a screen shot of what I'm seeing.


Messages In This Thread
Ajax msg display help! - by El Forum - 10-19-2010, 01:37 PM
Ajax msg display help! - by El Forum - 10-19-2010, 02:02 PM
Ajax msg display help! - by El Forum - 10-19-2010, 02:17 PM
Ajax msg display help! - by El Forum - 10-19-2010, 02:20 PM
Ajax msg display help! - by El Forum - 10-19-2010, 02:33 PM
Ajax msg display help! - by El Forum - 10-19-2010, 02:34 PM



Theme © iAndrew 2016 - Forum software by © MyBB