简体   繁体   English

Jquery Json Parse错误

[英]Jquery Json Parse error

This time I am locked by the Json Parse error. 这次我被Json Parse错误锁定了。 Currently I am Developing Web application in Asp.net MVC 4 with jQuery Mobile.In pages where I have text box and button , this issue occurs 目前我正在使用jQuery Mobile在Asp.net MVC 4中开发Web应用程序。 在我有文本框和按钮的页面 ,出现此问题

I am using jquery 2.1.1 js file .. Error Occuring in 我正在使用jquery 2.1.1 js文件 ..错误发生在

jQuery.parseJSON = function( data ) {
    return JSON.parse( data + "" ); // Here data comes as undefined 
};

Code in the View The below has textbox and buttons in my page 视图中代码下面的页面中有文本框和按钮

 <div class="HwySearchTextBoxSmaller">
                            @Html.TextBoxFor(Model => Model.txtPickingScan, new { @autofocus = "autofocus" })
                        </div>

                        <div id="btn" style="float: left; margin-top: 1.2em; margin-left: 1em;">
                            <input type="submit" id="btnSearchMP" name="btnSearchMP" class="Hwy905SearchIcon" data-role="none" value="" />
                        </div>
<div id="dButton">

                    <input type="submit" id="btnMPSearch" name="btnMPSearch"  data-theme="d" value="@Resources.ViewBatch"  />
                    <input type="submit" id="btnMPSearch1" name="btnMPSearch"  data-theme="d" value="@Resources.ViewGrp"  />
            </div>

Whenever I enter into text box , on blurring, on button clicking, on keyup and for other related events this error is popping up 每当我进入文本框,模糊,按钮点击,键盘和其他相关事件时,这个错误就会弹出

The error picture I have uploaded. 我上传的错误图片。 Json Parse错误

page is not working in any browser because of this issue. 由于此问题,页面无法在任何浏览器中运行。

Please Please help me . 请帮帮我。 Definitely I need to find a solution for this. 当然,我需要为此找到解决方案。 Please help me 请帮我

Instead of using jquery 2.1.1 file I used the Google api , for jquery libray which also showed the samer error 我没有使用jquery 2.1.1文件,而是使用了Google api,因为jquery libray也显示了相同的错误

Below is the dom image of the code 下面是代码的dom图像 在此输入图像描述

Try to improve your function in a kind like that: 尝试以这样的方式改进你的功能:

jQuery.parseJSON = function (data) {
   console.log(data + "");
   return JSON.parse(data + "");
};

Ensure that the caller of the $.parseJSON function supplies a correct formatted parameter "data". 确保$ .parseJSON函数的调用者提供正确的格式化参数“data”。 You can use the debugger of the browser to inspect the caller stack. 您可以使用浏览器的调试器来检查调用程序堆栈。

I think your issue is related to JSON data. 我认为您的问题与JSON数据有关。 There could be issues with the syntax of the JSON that you are using. 您正在使用的JSON 语法可能存在问题。 I would suggest that you validate the JSON online using some online JSON Validator tools like http://jsonformatter.curiousconcept.com . 我建议你使用一些在线验证 JSON在线JSON Validator工具,如http://jsonformatter.curiousconcept.com Once you have corrected the JSON, use the same JSON by hardcoding it in your code to test this scenario. 纠正JSON后,通过在代码中对其进行硬编码来使用相同的JSON来测试此方案。

Hi Got the solution for the above problem. 您好解决上述问题。 Actually while bundling the js files I removed validate and validate unobtrusive js files and the problem got solved . 实际上,在捆绑js文件时,我删除了验证和验证不显眼的js文件,问题得到了解决。 Thank you to all for helping me 谢谢大家的帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM