How to post the Code Ajax Post With Array

Jayakumars
Posted by Jayakumars under ASP.NET AJAX category on | Points: 40 | Views : 1436
I have post the Code Ajax Post With Array

function SaveToDbs() {
var myCars = new Array();
myCars[0] = document.getElementById("<%= TxtTab1.ClientID %>").value;
myCars[1] = document.getElementById("<%= TxtTab2.ClientID %>").value;
myCars[2] = document.getElementById("<%= TxtTab3.ClientID %>").value;

$.ajax({
type: "POST",
url: "/InsertCust.aspx/SaveToRecords",
data: JSON.stringify({ arr: myCars }),
contentType: "application/json; charset=utf-8",
dataType: "json",
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
},
success: function (result) {
alert(result.d);
}
});
return false;
}


<System.Web.Services.WebMethod()> _
<Script.Services.ScriptMethod(responseFormat:=Script.Services.ResponseFormat.Json)> _
Public Shared Function SaveToRecords(RecStr As List(Of String)) As String
End Function

Comments or Responses

Login to post response