Return the Json data of the backend to the foreground.
Front-end JS proxy
$. Post ('/Book/getbookclassidbyname', {BookName: "travel operator"}, function (data ){
If (data! = 0) {if (parseInt ($ ("# BookClassID "). val () = data) {$ ("# dinfo "). find ("h4" Login .html ("travel operator-import information"); $ ("# trTeamNo "). show ();
// $ ("# TrTeamNo "). attr ("style", "");} else {$ ("# trTeamNo "). hide (); // $ ("# trTeamNo "). attr ("style", "display: none"); $ ("# dinfo "). find ("h4" ).html ("-") ;}} else {$ ("# trTeamNo "). hide (); // $ ("# trTeamNo "). attr ("style", "display: none"); $ ("# dinfo "). find ("h4" ).html ("- ");}});
The controller of the backend is replaced by the following:
Public JsonResult GetBookClassIDByName (string BookName)
{
Int BookClassID = BookClassRepository. getBookClassIdByName (BookName );
Return Json (BookClassID );
// IEnumerable <int> IbookClassList = BookClassRepository. getBookClassList ();
// Return Json (IbookClassList. Where (x => x. ParentID = Pid), JsonRequestBehavior. AllowGet );
}