Tag: json

JSON和意外的字符

考虑到这个结果,我得到了一个ajax调用: [ { “field1”: “2381”, “field2”: “1233”, “field3”: “43.79489333333333”, “field4”: “11.22697833333333” }, { “field1”: “2381”, “field2”: “1774”, “field3”: “45.70752833333334”, “field4”: “9.489278333333333” } ] 并且有一个ajax调用它会一直返回“意外字符”错误,我有这样的调用我使用: jQuery.ajax({ type: “GET”, dataType: “json”, url: “/myUrl.php”, success: function(data) { console.log(data); var arrayObjects = JSON.parse(data); } }); 所以,自从我在互联网上阅读这种ajax电话后,它说: [{“value”: “test”}] is valid 所以我想知道为什么我的对象不断返回“意外的角色”。

如何删除parsererror:SyntaxError:位于0的JSON中的意外标记<

我试图使用PHP从MySQL数据库中获取数据并将其作为JSON传递。 当我尝试显示响应时,它会显示错误parsererror:SyntaxError:在位置0的JSON中出现意外的令牌。有人可以帮忙。 下面是我的jQuery和PHP代码: jQuery的: $(document).ready(function() { $(“#display”).change(function() { var type = document.getElementById(‘display’).value; alert(type); $.ajax( { //create an ajax request to load_page.php type: “GET”, url: “DBOperations.php”, data : “type=” +type, dataType: “json”, //expect text to be returned success: function(response) { //$(“#response”).html(response); //alert(response.); $.each(response, function(index, element) { $(‘#response’).html($( { text: element.name })); }); }, error: function(jqXHR, textStatus, […]

通过jQuery在ASMX Web服务中实际使用JSON的示例

任何人都可以推荐一篇关于向asp.net Web服务(任何风格)发送和接收JSON的文章,该文章使用比“hello world”更实用的例子。 理想情况下,涵盖以下主题: 从Web服务接收单个复杂对象(以表单forms显示) 从Web服务接收复杂对象的集合(显示在表中) 将单个复杂对象发送到Web服务(用于更新数据库) 将复杂对象的集合发送到Web服务(用于更新数据库)

jQuery循环遍历JSON对象

我想循环遍历这个JSON文件(下面的结构),并获得所有国家都是奥地利的酒店。 使用getJson()所以我也无法更改JSON文件中的任何内容。 任何帮助将不胜感激。 [ { “Site ID”: 19955, “Hotels”: “Ramada Salzburg City Centre”, “Stadt”: “Salzburg”, “Country”: “Austria”, “Region”: “Central & Eastern Europe”, “Link DE”: “”, “Link EN”: “”, “Link TR”: “”, “Lat”: 47.8137521, “Long”: 13.044259, “Image”: “/Salzburg.jpg” }, { “Site ID”: 1211, “Hotels”: “test”, “Stadt”: “Salzburg”, “Country”: “NZ”, “Region”: “Central & Eastern Europe”, “Link DE”: […]

MVC ListBox没有将数据传递给Action

当我使用FireBug时,我看到selectedPrdLctn的选定值正确设置但是当我通过JSON将其传递给我的动作时,它是一个null $.getJSON(‘@Url.Action(“GetCS”)’, { cntrParam: selectedPrdLctn }, function (getCS) { 我的行动 public ActionResult GetCS(String[] cntrParam) 如果我使用dropDownList,代码可以工作。 知道为什么我没有通过选择吗?

空JSON对象检查

当我控制打印时,我得到var a的值为Object {},这是空的JSON对象使用jQuery如何检查空值? 谢谢。

检查最后一页和第一页并相应地禁用下一个上一个按钮

我有两个弹出窗口显示用户列表和管理列表,每页显示10个结果,这很好。 我得到的页面没有。 来自JSON中的java servlet。 注意:url中传递了2个参数 – resType和pageNo。 您做生意。 返回0,10,20 ……(10的倍数)。 resType:检查我想要的结果类型。 你可以忽略这部分。 所以我在createTable函数中的url看起来像这样 – 当它是第一页时,如何禁用上一个按钮? 同样,如果它是最后一页,如何禁用最后一个按钮? 这是代码。 var currentPageNo = 0; // Keep track of currently displayed page $(‘.next-btn’).unbind(“click”).on(“click”,function(){ // Give buttons an ID (include them in HTML as hidden) userList(currentPageNo+10); adminList(currentPageNo+10); }); $(‘.prev-btn’).unbind(“click”).on(“click”,function(){ userList(currentPageNo-10); adminList(currentPageNo-10); }); function userList(pageNo) { var resType=”userList”; createTable(resType,pageNo); } function […]

Google地图上的JSON Feed没有显示任何内容

我希望谷歌地图显示标记与JSON提要。 但它不起作用。 我找不到实际的问题。 所以这是我的代码: var map; // The JSON data var json = [{ “OpperationErrorMsg”:””, “IsSuccess”:true, “ResultId”:1000, “Timestamp”:”2016-10-12T18:00:07.0232702Z”, “Echo”:null, “InSandbox”:true, “DebugMessages”:[ ], “MissingDetails”:[ ], “ResponseData”:[ { “CallTimeLocal”:”2016-10-10T06:28:48.7330000″, “IncidentId”:3374, “IncidentNumber”:”HC2016004034″, “CallTime”:”2016-10-10T10:28:48.7330000″, “ElapsedSeconds”:0, “Location”:”2712 E HANNA AVE”, “BuildingName”:null, “BuildingNumber”:null, “NatureId”:6743, “FirePriorityId”:1, “CoordinateX”:-82.429500000000, “CoordinateY”:28.003389000000 }, { “CallTimeLocal”:”2016-10-10T11:28:36.7000000″, “IncidentId”:3382, “IncidentNumber”:”HC2016004042″, “CallTime”:”2016-10-10T15:28:36.7000000″, “ElapsedSeconds”:0, “Location”:”1220 APOLLO BEACH BLVD S”, “BuildingName”:”Apollo Beach […]

如何在grails 2.0中获得JSON

我用jQuery发送自己的JSON: $.ajax ({ type: “POST”, url: ‘http://localhost:8080/myproject/myController/myAction’, dataType: ‘json’, async: false, //json object to sent to the authentication url data: {“stuff”:”yes”, “listThing”:[1,2,3], “listObjects”:[{“one”:”thing”},{“two”:”thing2″}]}, success: function () { alert(“Thanks!”); } }) 我发送给控制器然后做 println params 而且我知道我已经遇到麻烦了…… [stuff:yes, listObjects[1][two]:thing2, listObjects[0][one]:thing, listThing[]:[1, 2, 3], action:myAction, controller:myController] 我无法弄清楚如何获得这些价值的大部分…… 我可以用params.stuff获得“yes”,但我不能做params.listThing.each {}或params.listObjects.each {} 我究竟做错了什么? 更新: 我让控制器执行此操作以尝试到目前为止的两个建议: println params println params.stuff println params.list(‘listObjects’) […]

用户数据validation无效

我正在尝试使用CodeIgniter和jqueryvalidation登录表单。 我正在使用CodeIgniter的form_validation库。 当用户单击登录按钮时,表单将被提交并调用jquery函数。如果数据有任何问题,控制器函数会将错误消息作为json传递给jquery函数。 问题是错误消息没有显示在表单中。 唯一显示的是空白页面中的json数组。 这是html form : <form class="col-md-12 center-block" action='hyr/proceso’ method=’post’ name=’proceso’ id=’hyrForm’> Hyr 这是jquery函数: function hyr() { $(“.text-danger”).remove(); $(“.form-group”).removeClass(‘has-error’).removeClass(‘has-success’); $(“#hyrForm”).unbind(‘submit’).bind(‘submit’, function() { $.ajax({ url: form.attr(‘action’), type: form.attr(‘method’), data: form.serialize(), dataType: ‘json’, success:function(response) { if(response.sukses===false) { $(‘.text-danger’).remove(); if(response.mesazhe instanceof Object) { $.each(response.mesazhe, function(index, value) { var id = $(“#”+index); id .closest(‘.form-group’) .removeClass(‘has-error’) .removeClass(‘has-success’) […]