Specify View to Return through JSON

There is a specific line of code I am looking at:

return Json(new { status = true, returnUrl = "ThankYou" }, JsonRequestBehavior.AllowGet);

I have not been able to understand how exactly this works. This is in a controller. A form is submitted, this code is reached and returns through this line of code. It then opens a shared view, ThankYou.cshtml, and displays the expected content.

This is an issue for me because there is similar code that is not working as before:

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

The second line of code use to work similarly to the first, but now it is just returning text to the browser. I'm not sure what changed.

Anything to point me in the right direction?

Upvotes: 0

Views: 77

Answers (1)

Adlorem
Adlorem

Reputation: 1507

In first case you are returning object to view. You should check your javascript part in view. There should be a code that redirects user to page specified in returnUrl = "ThankYou" page.

In second case you are just returning text.

Upvotes: 1

Related Questions