Saturday, 10 August 2013

How to change button class after calling asp method with jQuery?

How to change button class after calling asp method with jQuery?

i have aspx web page that contains 500 button (input type="button") that
they creates in run time. Each button has this class: button button-green
, and i call the click method with jQuery. My question is : how can i
change the class of the button after finish post back from server to
client and change the button classes?
this is my code :
<script type="text/javascript">
$(document).ready(function() {
$(".button").click(function() {
var sid = '<%= Request.QueryString["SID"] %>';
var m = '<%= Request.QueryString["M"] %>';
var row = $(this).attr("value");
var col = $(this).attr("SkinID");
var classs = $(this).attr("class");
$(this).attr("class", "button load");
var DTO = {
'sid': sid,
'm': m,
'row': row,
'col': col
};
$.ajax({
type: "POST",
url: "WebService.asmx/AddChairs",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(DTO),
success: function(response) {
var classs = $(this).attr("class");
$(classs).attr("class", "button button-blue");
},
error: function(response) {
alert(response.d)
}
});
});
});
</script>

No comments:

Post a Comment