One of my friend while doing a task of a project , he implemented the Ajax call to send request to the action method. he had done it and resend the model to the client side, but the data is not updating in the view.
So, I thought of a while and scrutinized it and found that the model is updated when the data comes from the action method but it is not updating the view. so, here is the trick how to do it.
$.ajax({
data: { retailLocation: $("#ddlLanguages").val().split('-')[1] + "-" + this.value },
url: '/App/index',
success: function (result) {
$("#container").empty().html(result);
$('#container').fadeIn('fast');
},
complete: function (result) {
$("#RetailPartnerLocation option:contains(" + currentselection + ")").attr('selected', 'selected');
},
Error: function (result) { alter("Error occured while processing"); }
});
Here you need to empty the container where the previous data exist and bind the new data to it.
So, I thought of a while and scrutinized it and found that the model is updated when the data comes from the action method but it is not updating the view. so, here is the trick how to do it.
$.ajax({
data: { retailLocation: $("#ddlLanguages").val().split('-')[1] + "-" + this.value },
url: '/App/index',
success: function (result) {
$("#container").empty().html(result);
$('#container').fadeIn('fast');
},
complete: function (result) {
$("#RetailPartnerLocation option:contains(" + currentselection + ")").attr('selected', 'selected');
},
Error: function (result) { alter("Error occured while processing"); }
});
Here you need to empty the container where the previous data exist and bind the new data to it.
No comments:
Post a Comment