<script type="text/javascript">
$('#Add').click(function() {
$.ajax({
url: '<%= Url.Action(AjaxAddStopPoint , new { Id = Model.Service.Id })%>?StopPointId=' + $("#StopPoints option:selected").val(),
type: "POST",
success: function(result) {
refreshServiceStopPointsGrid();
},
error: function(xmlHttpRequest, textStatus, errorThrown) {
if (xmlHttpRequest.readyState == 0 || xmlHttpRequest.status == 0)
return; // it's not really an error. A situation could be where the user has canceled an ajax request during an ajax request.
else {
if (xmlHttpRequest.status == 500) // server side set. we have an error
{
alert(xmlHttpRequest.responseText); // display it
}
}
}
});
});
function refreshServiceStopPointsGrid() {
var grid = $('#ServiceStopPointListGrid').data('tGrid');
grid.rebind();
}
</script>
But what about if I have a on the grid, rows of data. And the user hits delete on one of them but then the server cannot delete (for whatever reason) - how do I catch the error like above, for that row?
where and how would I bind the event to that row, so it can catch the error through the AJAX delete command?