I have a jQuery ajax service call like the one below, this is called when a user clicks ok on an Edit dialog. The dialog contains a textbox which the user should use to edit the content of a paragraph section on the webform.
//Example of my real call
function testService(test) {
var person = {};
person.ID = 1;
person.name = "Albert";
$.ajax({
type: "POST",
url: "WebService1.asmx/HelloWorld",
dataType: "json",
data: "{person:" + JSON.stringify(person) + "}",
contentType: "application/json; charset=utf-8",
success: function (response) {
},
error: function(response) {
alert(response.d);
}
});
}
The problem is the webform paragraph section isn't updated with the newly updated value, because I have not carried out a client update.
The question is: what is the best approach in getting the refreshing the client with the newly updated string from the DB. Should I make another web service call to get the value from the DB ? I know that can take a long time and be unnecessary, is there a jQuery trick to doing this? And I only want to refresh that paragraph section, not the whole page
On a POST you should return the complete object you have updated to the client. Then use the response from the server to update the webpage.
With this approch so can the DB be responsible for adding some information to the object like ID creation date etc. And you will have the updated object on the clientside when the POST has succeeded.