2

This seems so basic but for whatever reason I can't get it to work.

Jquery..

$.post("/Member/Profile", "TESTDATA", function (result) {
    console.log(result);
});

Controller

[HttpPost]
public JsonResult Profile(string model)
{
    return Json(1);
}

My string model parameter is coming in as null, I can see that when I breakpoint on it. I've tried making it pass json, tried making it pass viewmodels, tried using ajax with Type/Method as "POST".. My parameter always seems to be coming in as null. What am I doing wrong?!

1
  • Just commenting as I may hit this issue again so this may only be relevant to me. This stemmed from trying to convert my knockoutJS viewmodel to json and pass that to my controller as the viewmodel object. The controller was getting a nulled object; I realised it can accept a plain javascript object (not a json though). So what I really needed to do was convert my knockoutjs viewmodel to a javascript object and pass that as my data. JSON.parse(ko.mapping.toJSON(self)); Commented Dec 11, 2015 at 11:17

2 Answers 2

3

Try this one?

$.post("/Member/Profile", {model: 'TESTDATA'}, function (result) {
    console.log(result);
});
Sign up to request clarification or add additional context in comments.

Comments

2
try this
$.post("/Member/Profile", {model:'TESTDATA'}, function (result) {
    console.log(result);
});

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.