Hi folks,

I've tried, but I just cannot get my head in the right direction with this one.

In a non-ajax application I have, if a database record is successfully updated, the return stream from the server contains an appropriate message of the form:

<p class="alert">The record was successfully updated</p>

If an error occurs, the message is of the form:

<p class="alert">Error - the record was not updated</p>

I currently "jquery" the stream via:

$(".alert").highlightFade({color:'red',speed:2000,iterator:'sinusoidal'});

I'd like now to be more user friendly and alter the fade colour to red only if the message contains the word "Error", with the colour to be green for all other messages.

The code below is my attempt, but it fails because I cannot work out how to "transfer" the message to myString (for subsequent testing of the presence of "Error" - how should I be doing this?

    $(".alert").filter(function(chekit){var myString=???????;
        //console.log(myString.indexOf("Error"))
        if (myString.indexOf("Error")>0)
        {
        
$(".alert").highlightFade({color:'red',speed:2000,iterator:'sinusoidal'});
        }
        else
        {
        
$(".alert").highlightFade({color:'green',speed:2000,iterator:'sinusoidal'});
        };
    });

What should be in ???? - I've tried $(this).html and similar permutations, but none (of these guesses) worked.

Thanks,

Bruce



Reply via email to