callback success/error not working

callback success/error not working

For some reason the success and error callbacks are not working at all. I'm using jquery.ajax to submit a form w/o page refresh through a php file. I have set the success & error callbacks but even when I changed the mysql password (to a incorrect one) I got the success message :S

here's the php & js script

  1. <?php

    /*$fp = fopen('data.txt', 'a+');
    fwrite($fp, 'ok');
    fclose($fp);*/

    $sections = $_REQUEST['sections'];
    $fontColor = $_REQUEST['fontColor'];
    $bgcolor = $_REQUEST['bgcolor'];
    $font = $_REQUEST['font'];
    $fontSize = $_REQUEST['fontSize'];
    $lineHeight = $_REQUEST['lineHeight'];
    $letterSpacing = $_REQUEST['letterSpacing'];
    $fontStyle = $_REQUEST['fontStyle'];
    //$tekst = $_REQUEST['tekst']

    $connect = mysql_connect("localhost", "root", "password") or die ("Unable to connect to the database");
    mysql_select_db("ipsum") or die ("doesnt exist: " . mysql_error());

    $update = "INSERT INTO con (Sections, Fontcolor, BackgroundColor, Font, FontSize, LineHeight, LetterSpacing, FontStyle) VALUES ('".$sections."', '".$fontColor."', '".$bgcolor."', '".$font."', '".$fontSize."', '".$lineHeight."', '".$letterSpacing."', '".$fontStyle."')";



    // the content of 'data.txt' is now 123 and not 23!


    mysql_query($update) or die ("unable to update: " . mysql_error());

    mysql_close($connect);


    ?>































  1. // JavaScript Document

    $(function(){
    $('.save').click(function(){
       
       
       
        var sections = $('#sections').attr('value');
        var fontColor = $('#fontColor').attr('value');
        var bgcolor = $('#bgcolor').attr('value');
        var font = $('#font').attr('value');
        var fontSize = $('#fontSize').attr('value');
        var lineHeight = $('#lineHeight').attr('value');
        var letterSpacing = $('#letterSpacing').attr('value');
        var fontStyle = $('#fontStyle').attr('value');
        //Datastring to pass through
                     
        var dataString = {sections:sections, fontColor:fontColor, bgcolor:bgcolor, font:font, fontSize:fontSize, lineHeight:lineHeight, letterSpacing:letterSpacing, fontStyle:fontStyle};         
                     
        $.ajax({
    type: "POST",
    url: "update.php",
    data: dataString,
    success: (function(){$('#successMessage').fadeIn("slow").delay(1000).fadeOut(2000);}),
    error: (function (){$('#errorMessage').fadeIn("slow").delay(1000).fadeOut(2000);}),

           
        });
        return false;
       
    });
    });