2

I have this:

$.getJSON("https://scyk.pl/Account/GetSid").done(function (sid) {
    settings.parameters.sid = sid;
});

And this:

public JsonResult GetSid()
{
    return Json(SomeString);
}

.done function of jquery is not executing - why?

2
  • And how do you know its not executing? Commented Apr 21, 2013 at 18:07
  • settings.parameters.sid is null, also if I put console.log("done") in there, nothing happens Commented Apr 21, 2013 at 18:10

1 Answer 1

4

Use the override of Json that takes a JsonRequestBehavior option and set that to AllowGet

return Json("string", JsonRequestBehavior.AllowGet);

To only allow post requests, change your controller action to this:

[HttpPost]
public JsonResult GetSid()
{
    return Json(SomeString);
}
Sign up to request clarification or add additional context in comments.

2 Comments

Then you shouldn't set the request behavior, but of course use jQuery's Ajax method instead of getJson.
And if you want the restrict requests so that only POST are allowed, add [HttpPost] above the method.

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.