DIfferent URL Has To Be Passed For Same Ajax Call
I am doing add and edit operation. To perform edit operation I have used the below link for reference and finished it. If I click the edit button I can see popup form with detai
Solution 1:
By Making the common function for the Ajax:
function doAjaxCall(var url,var data,var method,var callBackFunction)
{
$.ajax({
type: method,
url: url,
data: data,
success: function(data){
callBackFunction(data);
}
});
}
Call the Function like this
function onAdd(data){
// Code to append
}
doAjaxCall("/add",userData,"POST",onAdd);
function onEdit(data){
// Code to update
}
doAjaxCall("/update",userData,"PUT",onEdit);
Solution 2:
Store your url in a string variable. Depends on add/edit button onClick, change the url string of that variable and pass that variable in ajax call url attribute.
Post a Comment for "DIfferent URL Has To Be Passed For Same Ajax Call"