#1
  1. No Profile Picture
    frequent PHP idiot
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    354
    Rep Power
    12

    Ajax says error, but still posts


    Here's my jquery.

    PHP Code:

    $(document).ready(function(){
    $(
    "#commentform").submit(function() {
            var 
    serial = $(this).serialize();
            
    /* code from above, changing form selector to "this" */
            
    $.ajax({
                
    type"POST",
                
    url"comment_ajax.php",
                
    dataserial,
                
    dataType"json",
                
    success: function(msg) {
                    
    alert("Data Saved: " msg.project_id msg.name msg.task_order msg.status)
                },
                
    error: function() {
                    
    alert("nope"+serial)
                }
            });
            return 
    false;
        });

    }); 
    the problem is, it always shows error, but comment_ajax.php is still able to write to my database each time without any trouble. It basically succeeds at everything except know it was successful. What gives???
    Last edited by soupman99; May 14th, 2013 at 11:24 PM.
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7170
    My best guess is that your PHP file isn't returning valid JSON.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo