I have some problem ajax with query string, I can send the data if page does not have and Info.aspx/Save works great. But when I fill somethings with query string then post same data it will return http 500 error. I have nothing with querystring in javascript I use it in C# for id.
var data = '{name: "' + $("input[name$='name']").val() +
'",description: "' + $("input[name$='description']").val() +
'",code: "' + $("input[name$='code']").val() +'"}';
$.ajax({
type: "POST",
url: "Info.aspx/Save",
data: data,
contentType: "application/json",
dataType: "json",
success: function (data) {
var result = data.d
console.log(result)
if (result > 0)
success.show();
else
error.show();
Metronic.scrollTo(error, -200);
},
error: function () {
console.log('err')
}
});
[WebMethod]
public static int Save(string name, string description, string code)
{
ClassInfo classInfo = new ClassInfo();
return ClassInfo.Save(name, code, description, FileInfo.id);
}
I just use querystring in C# for filling inputs. Altough I send same data it works without querystring inpgae's adressbar, If it has querystring in addressbar ajax returns me http500 error and Save WebMethod does not work.
JSON.stringify(data);