Welcome Guest, Not a member yet? Register   Sign In
An Ajax Request Problem
#1

[eluser]barisv[/eluser]
Hi,

I am filling a form and echo out a true or false according to a function.

Code:
$.ajax({
        url: "<?php echo site_url('admin/addnews'); ?>",
        type: 'POST',
        data: form_data,
        success: function(msg) {
            
                        
                    alert(msg);
            
                            
                    if(msg == 'true')
                    {      
                        $('.fail').remove();                  
                        $('.success').fadeIn(500);
                        
                        $('#name').attr("readOnly", "readonly");
                        $('#message').attr("readOnly", "readonly");
                        $('#submit').attr("readOnly","readonly");
                    }
                    
                    else
                    {
                            
                        
                        $('.fail').hide().fadeIn(500);
            
                        
                    }
                
                
        }

});

Even if the alert method returns true, it enters the else part. What can be the problem ?

Thanks in advance.
#2

[eluser]byde[/eluser]
try
Code:
if(msg == "true")

if it doesnt work try numbers
#3

[eluser]barisv[/eluser]
Great advice. It worked. Thank you.




Theme © iAndrew 2016 - Forum software by © MyBB