Only return a value via json - Receive it in my js ajax

  • Thread starter Thread starter Jesper Petersen
  • Start date Start date
J

Jesper Petersen

Guest
It is true that I need to have a single value over to my js ajax but when it is that I try to get my value over to ajax js. Then it informs me of this error


Object reference not set to an instance of an object.

I've been trying to figure out how to do it with json and I just haven't found any solution to it at all.

So where my PiinVoice lies there are also a lot of other values that I use.

Basically, it is only PiinVoice that I have to get out to my js ajax

Controller:

model.PiinVoice = subscription.LatestInvoice.PaymentIntent.ClientSecret;
return Json(model);


I have added this to my httppost:

[Produces("application/json")]

js file here:

$.ajax({
url:
'/Members/AddMembership/' + Id + '/' + CompaniesId, //jump to httppost action,meet [Route("Members/AddMembership/{id}/{CompaniesId}")]
dataType:
"json",
data:
"",
type:
"Post",
contentType:
'application/json',
success: function (result) {
//receive response from httppost action
//result is the response of the httppost action,you can handle it
console.log(
"New: " + Id, CompaniesId);
console.log(result)
//Object reference not set to an instance of an object.

},
error: function (xhr) {
console.log(xhr)
}
});


My question then goes on: How I get done so that my json can state the requirements in relation to Object reference not seen to an instance of an object.

Continue reading...
 
Back
Top