Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hot to convert html data into json and get all record into web method then store into database using datatable

it not work

What I have tried:

$.ajax({

var table = document.getElementById("table");
var r = tableToJson(table);
console.log(r);

type: "POST",
url: "CourseSubTopicMaster.aspx/SaveData",
data: "{'json' : " + JSON.stringify(r) + "}",
processData: false,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});


[WebMethod]
public static string SaveData(string data)
{
}
Posted
Updated 26-Jun-19 1:11am
v4
Comments
Dominic Burford 26-Jun-19 7:03am    
So where exactly is it failing? Are you getting an error? More detail is required.
Member 13484654 26-Jun-19 7:08am    
ok
Member 13484654 26-Jun-19 7:08am    
$('#Button1').click(function () {
var table = $('#table').tableToJSON(); // Convert the table into a javascript object


console.log([table]);
alert(JSON.stringify(table));

JSON.stringify({ obj: javascriptObject });
$.ajax({
type: "POST",
url: "CourseSubTopicMaster.aspx/GetCurrentTime",
data: { name: JSON.stringify(table) },
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});

});
Member 13484654 26-Jun-19 7:09am    
but web method not calling that is my error
[webmethod]
public static string GetCurrentTime(string name)
{
}|
ZurdoDev 26-Jun-19 7:21am    
Then use the developer tools in your browser to find out what is happening. Your url might be wrong. Or data may be throwing an exception. Add the error handler to your ajax call and see if that is called.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900