Ich habe ein Problem, dass, wenn ich Testbox-Werte durch JQuery AJAX übergeben kann ich nicht Werte im Code hinter sehen.kann Parameter von jQuery Ajax Code hinter c nicht übergeben #
function CreateComplaint(){
var category = $('#ddlCompCategory') .val();
var name = $('#txtCompUserName') .val();
var subject = $('#txtCompSub') .val();
var mobile = $('#txtCompMobileNo') .val();
var address = $('#txtaCompAddr') .val();
var email = $('#txtCompEmail') .val();
$('#spinnerAddComplaint').show();
CreateComplaintXHR(
'/api/Complaints/CreateComplaint',
{
Token : RBApp.Token,
CategoryId : category,
UName : name,
Subject : subject,
Mobile : mobile,
Email : email,
Address : address
}, ....}
Ajax-Funktion:
function CreateComplaintXHR(url, data, success, error, alWaysCallback) {
$.ajax({
url: url,
type: 'POST',
dataType: 'json',
data: data,
success: function (data, textStatus, jqXHR) {
if (success)
success(data, textStatus, jqXHR);
},
error: function (jqXHR, textStatus, errorThrown) {
if (error)
error(jqXHR, textStatus, errorThrown);
}
}).always(function() {
});
}
Code hinter:
[HttpPost]
[ActionName ("CreateComplaint")]
public ResponseModel InsertComplaintMethod(InsertComplaint Complaint)
{
log .Debug ("Create Complaint request received : ");
log .Debug ("Request params : " + Complaint .Serialize());
User user = loadUser (Complaint .Token);
ComplaintsAdapter adapter = new ComplaintsAdapter (user);
ResponseModel response = adapter .CreateComplaintOrSuggestion (Complaint);
return response;
}
InsertComplaint
public class InsertComplaint
{
//public string Token { get; set; }
public string Lat = "0"; //{ get; set; }
public string Lng = "0"; //{ get; set; }
public string deviceID = "0";
public string complaintSubject { get; set; }
public string complaintText { get; set; }
public string name { get; set; }
public string phoneNumber { get; set; }
public string attachements = null;
}
In insertComplaintMethod Funktionsobjekt Beschwerde wird immer keine Werte statt dessen showin g Null. ist das das Problem, weil in Ajax-Funktion Daten weniger Parameter als in Reklamationsobjekt, das mehr Eigenschaften hat. Jeder kann helfen. danke im voraus.
Danke mann. Ich habe 2 Tage damit verbracht, die Probleme herauszufinden. Es klappt. Danke noch einmal. –
Sie sind herzlich willkommen! – Pavlo