0

I have a this JavaScript function:

function notificationDivPressed(element,userId,numberOfUsers) {
   $.ajax({
      url: '/Notification/ChangeReadStatus',
      type: "POST", cache: false,
      data: { arg: userId },
      success: function (data) {
         //some code
      }
    });

and this is ChangeReadStatus() function from Controller:

[HttpPost]
public void ChangeReadStatus(string id)
{
   //some code
}

why 'id' value in ChangeReadStatus is equal to 'null'?

3
  • datatype: json needed Commented Jan 10, 2014 at 15:30
  • @Ani: Wrong; MVC is perfectly capable of handling form posts. Commented Jan 10, 2014 at 15:33
  • 1
    just change your data to: "data : { "id" : userId } Commented Jan 10, 2014 at 15:33

1 Answer 1

6

Because your HTTP requests passes arg, not id.

If you want to pass a parameter, you need to pass it with the same name.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.