Ho un codice come questo: sto usando il valore Data come oggetto letterale, invece di concatenare una stringa. PERCHÉ? see hereMessaggio: primitiva JSON non valida: metodo jquery ajax con C# Webmethod
il mio codice è questo: -
$.ajax({
url: "../Member/Home.aspx/SaveClient",
type: "POST",
async: false,
dataType: 'json',
contentType: 'application/json; charset=utf-8',
data: {
"projectSoid": ProjectId,
"startDate": StartDate,
"endDate": EndDate,
"clientManager": ClientManager
},
success: function (response) {
if (response.d != "") {
}
},
error: function (response) {
var r = jQuery.parseJSON(response.responseText);
alert("Message: " + r.Message);
alert("StackTrace: " + r.StackTrace);
alert("ExceptionType: " + r.ExceptionType);
}
})
e webmethod è come questo:
[WebMethod]
public static string SaveClient(string projectSoid, string startDate, string endDate, string clientManager)
{}
Il problema è che ho ottenuto errore come questo:
messaggio: Invalid JSON primitiva : projectSoid
È necessario JSON.strigify i dati: 'data: JSON.strigify ({ " projectSoid ": ProjectId, " startDate ": StartDate, " endDate ": EndDate, " clientManager ": Clien tManager }), ' – nemesv
Qualche commento sul mio commento? L'hai provato? Ha funzionato? – nemesv
non so cosa sia JSON.strigify? Ho un errore che non funziona :( –