i have few textbox on the form and when the user submit i want to capture the data and insert into db
here is what my code looks like
beforeSubmit: function(data)
{ // called just before the form is submitted
var item = $("[id$='item']");
var category = $("[id$='category']");
var record = $("[id$='record']");
var json = "{'ItemName':'" + escape(item.val()) +
"','CategoryID':'" + category.val() + "','RecordID':'" + record.val() + "'}";
//this page is where data is to be retrieved and processed
var ajaxPage = "DataProcessor.aspx?Save=1";
var options =
{
type: "POST",
url: ajaxPage,
data: json,
contentType: "application/json;charset=utf-8",
dataType: "json",
async: false,
success: function(response)
{
alert("success: " + response);
},
error: function(msg)
{
alert("failed: " + msg);
}
};
//execute the ajax call and get a response
var returnText = $.ajax(options).responseText;
if (returnText == 1) {
record.html(returnText);
$("#divMsg").html("<font color=blue>Record saved successfully.</font>");
}
else
{
record.html(returnText);
$("#divMsg").html("<font color=red>Record not saved successfully.</font>");
}
// $("#data").html("<font color=blue>Data sent to the server :</font> <br />" + $.param(data));
},
here is what is the Data sent to the server: if i uncomment this line:
// $("#data").html("<font color=blue>Data sent to the server :</font> <br />" + $.param(data));
_VIEWSTATE=%2FwEPDwULLTE4ODM1ODM4NDFkZOFEQfA7cHuTisEwOQmIaj1nYR23&_EVENTVALIDATION=%2FwEWDwLuksaHBgLniKOABAKV8o75BgLlosbxAgKUjpHvCALf9YLVCgLCtfnhAQKyqcC9BQL357nNAQLW9%2FeuDQKvpuq2CALyveCRDwKgoPWXDAKhwImNCwKiwImN &day_fi=12&month_fi=12&year_fi=1234&lastFour_fi=777&countryPrefix_fi=1&areaCode_fi=555-555&phoneNumber_fi=5555&email_fi=nisardotnet%40gmail.com&username=nisarkhan&password=123456&retypePassword=123456