Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

How can i return Json string from this ?

How can i return Json string from this ? And then use the json to use a ajax.public ActionResult RateMovie(FormCollection collection){string movieId = collection["movieid"];string rateInfo = collection["rateinfo"];if (String.IsNullOrEmpty(movieId)){return View("Error");}if(String.IsNullOrEmpty(rateInfo)){ return RedirectToAction("Detail", "MovieApp", new { id = movieId });}string username = System.Security.Principal.WindowsIdentity.GetCurrent().Name;int id = Int32.Parse(movieId);Rating rating = MovieAppRepository.Instance.GetRatingsByID(id).Where(x => x.Username == username).SingleOrDefault();if(rating != null){rating.rating = Int32.Parse(rateInfo);}else {Rating newRating = new Rating { MovieId = id, rating = Int32.Parse(rateInfo), Username = username };MovieAppRepository.Instance.AddRating(newRating);}return RedirectToAction("Detail", "MovieApp", new { id = movieId });/*$(document).ready(function () {$("#movieID").submit(function () {$.ajax({type: "POST",contentType: "application/json; charset=utf8",url: "/MovieApp/ReviewMovie/",data: $("movieID").serialize(),dataType: "json",success: function (data) {alert("Pulla og kók með sveppa krull")},});event.preventdefault();});});}

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question