var name = $get("txtName").value;
PageMethods.GetCurrentDate(name, OnSuccess, OnFailure);
}
function OnSuccess(result) {
if (result) {
alert(result);
}
}
function OnFailure(error) {
}
here GetCurrentDate id codebehind method name, in this method there are 3 parameters,how many parameters we can define here,how we can call methos in which grid view bind on given id through this method.
var obj1 = {};
obj1.mangerid = $.trim($("[id*=txtmanagerid]").val());
obj1.clientid = $.trim($("[id*=txtclientid]").val());
$.ajax({
type: "POST",
url: "sqlwebmethod1.aspx/GetChat",
data: JSON.stringify(obj1),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: OnError,
error: OnError,
});
return false;
});
function OnSuccess(response) {
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
var customers = xml.find("Table");
var row = $("[id*=grdchat] tr:last-child").clone(true);
$("[id*=grdchat] tr").not($("[id*=grdchat] tr:first-child")).remove();
$.each(customers, function () {
var customer = $(this);
$("td", row).eq(0).html($(this).find("message").text());
//$("td", row).eq(1).html($(this).find("ContactName").text());
//$("td", row).eq(2).html($(this).find("City").text());
$("[id*=grdchat]").append(row);
row = $("[id*=grdchat] tr:last-child").clone(true);
});
}
//i changed this code to
var m = document.getElementById("<%=txtmanagerid.ClientID%>").value;
var n= document.getElementById("<%=txtclientid.ClientID%>").value;
$.ajax({
type: "POST",
url: "sqlwebmethod1.aspx/GetChat",
data: '{managerid: "' + m + '",clientid:"'+n+'"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: OnError,
error: OnError,
});
return false;
});
function OnSuccess(response) {
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
var customers = xml.find("Table");
var row = $("[id*=grdchat] tr:last-child").clone(true);
$("[id*=grdchat] tr").not($("[id*=grdchat] tr:first-child")).remove();
$.each(customers, function () {
var customer = $(this);
$("td", row).eq(0).html($(this).find("message").text());
//$("td", row).eq(1).html($(this).find("ContactName").text());
//$("td", row).eq(2).html($(this).find("City").text());
$("[id*=grdchat]").append(row);
row = $("[id*=grdchat] tr:last-child").clone(true);
});
}
it's working but 1 have 2 script, showing data of last script only