-
Notifications
You must be signed in to change notification settings - Fork 0
POST Data from JS
KS LIM edited this page Apr 8, 2021
·
4 revisions
- In Javascript - you can pass the parameter with
jQuery.param({});
/***if your app upload outside Default Web site***/
var _url = "/";
/***if your app upload under Default Web site***/
//var _url = "/myProjectFolder/";
jQuery.ajax({
type: "POST",
url: url+'PROJECT/AddProcess',
data: jQuery.param({
id: parseInt(table.rows[ri].cells[5].innerText),
date: table.rows[1].cells[ci].innerText,
content: table_process.rows[ri_process].cells[1].innerText
}),
success: function (res) {
var table = document.getElementById("table_data");
table.rows[ri].cells[ci].innerText += table_process.rows[ri_process].cells[1].innerText;
}
});
- In c# controller
public void AddProcess(int id, String date, String content)
{
try
{
Database d = new Database();
string sql = "INSERT INTO " + d.process_table + "( " +
d.process_id + "," +
d.process_td_tms_id + "," +
d.process_date + "," +
d.process_content + " " +
")SELECT COALESCE(MAX(" + d.process_id + "::Integer),0)+1," +
"'" + id + "'," +
"'" + date + "', " +
"'" + content + "' " +
" FROM " + d.process_table;
Database db = new Database(sql, _server);
db.Close();
}
catch (Exception e)
{
TempData["alert"] = e.Message;
}
}