I am trying to reset the text of a button tag. When the user clicks on the button a ajax call is made and then changes the title of the button to the response message ( success or fail) And I need it to change back to Save if they want to make more changes. right now it just stays on the response message
// SAVE NEW STUDENT DETAILS
$('#save_student_detail_changes').live('click',function(){
$('#save_student_detail_changes').text('Save');
var changes ='&';
// FIND ALL THE INPUT CHILDREN OF #STUDENT_DETAILS AND INSERT THE VALUE ATTRIBUTE AND THE COL ATTRIBUTE INTO THEIR OWN VARIABLES
$('#student_details').find("input").each(function() {
var value = $(this).attr('value');// VARIABLE FOR VALUE ATTRIBUTE OF INPUT TAG
var column = $(this).attr('col');// VARIABLE FOR COL ATTRIBUTE OF INPUT TAG
changes += column + '=' + value + '&' ;// BUILDS THE AJAX QUERY STRING
var lin = $(this).parent().attr('rel');// GET ID ATTRIBUTE DETAILS
$(this).parent().attr('id',lin);// MAKE NEW ATTRIBUTE WITH DETAILS FROM ID ATTRIBUTE
$(this).parent().removeAttr('rel');// REMOVE ID ATTRIBUTE
$(this).replaceWith(value); // REPLACE INPUT ELEMENT WITH VALUE THAT WAS INSERTED
});
$(this) // AJAX CALL
.html(ajax_load) // SHOW LOADING SPINNING WHEEL
.load(loadUrl,"form_being_submitted=save_student_detail_changes"+changes);
$(this).fadeOut(3000);// FADE OUT SAVE BUTTON
I ended up using the .ajax() method. There is has a lot more control.
http://api.jquery.com/jQuery.ajax/