i want to post the follwing json to serever
{"jsonStr":[{"empid":10,"name":"Kev","dept":32}],"path":"D://koko.txt"}
my code is as follwing
var $empId = uniqId();
var $empName = $("#empName").val();
var $deptId = $("#dept").val();
var emp1 = new emp($empId, $empName, $deptId);
people.push(emp1);
obj.jsonStr = people;
obj.path = "D:
$.ajax({
type: "POST",
url: "Save.aspx/WriteJSON",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(obj),
dataType: "json",
success: function (r) {
alert(r.d)
},
error: function (x, e) {
if (x.status == 0) {
alert('You are offline!!\n Please Check Your Network.');
} else if (x.status == 404) {
alert('Requested URL not found.');
} else if (x.status == 500) {
alert('Internel Server Error.');
} else if (e == 'parsererror') {
alert('Error.\nParsing JSON Request failed.');
} else if (e == 'timeout') {
alert('Request Time out.');
} else {
alert('Unknow Error.\n' + x.responseText);
}
}
});
the following is returned
Internal Server Error
server code
public static string WriteJSON(string jsonStr, string path)
{
FileStream file = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
file.SetLength(0);
StreamWriter sr = new StreamWriter(file);
sr.Write(jsonStr);
sr.Close();
file.Close();
return "ok";
}
what is the solution