Wednesday, 9 January 2019

Uncaught ReferenceError: Y is not defined

Uncaught ReferenceError: Y is not defined

《before》
var getOdrReiTkts =  @Html.Raw(Json.Serialize(Model.OrdersReissueTickets));
            var strFinAccountInd = 'N';
            if (getOdrReiTkts["length"] != 0) {
                strFinAccountInd =  @Model.OrdersReissueTickets.Where(x => x.ID_SEQ == @ViewBag.ORTID_SEQ).First().FINANCE_ACCOUNT_IND ;
            }

《after》
var getOdrReiTkts =  @Html.Raw(Json.Serialize(Model.OrdersReissueTickets));
            var strFinAccountInd = 'N';
            if (getOdrReiTkts["length"] != 0) {
                strFinAccountInd =  '@Model.OrdersReissueTickets.Where(x => x.ID_SEQ == @ViewBag.ORTID_SEQ).First().FINANCE_ACCOUNT_IND' ;
            }


When you will use model value in javascript if-else statement, you should add '' to wrap the value to us.

Refer:
https://stackoverflow.com/questions/5863094/asp-net-mvc-using-viewdata-in-javascript

No comments:

Post a Comment

IIS HTTP Error 403.18

 HTTP Error 403.18 - Forbidden The specified request cannot be processed in the application pool that is configured for this resource on the...