{"id":2974,"date":"2014-03-12T23:59:34","date_gmt":"2014-03-12T23:59:34","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/12\/jqueryjsonrelated-issues-collection-of-common-programming-errors\/"},"modified":"2014-03-12T23:59:34","modified_gmt":"2014-03-12T23:59:34","slug":"jqueryjsonrelated-issues-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/12\/jqueryjsonrelated-issues-collection-of-common-programming-errors\/","title":{"rendered":"jquery,jsonRelated issues-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/5aba61bb4da54c969c3e8cd5c71da663?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAndreu Heineken<br \/>\njavascript jquery symfony1 jstree<br \/>\ni did a descendant tree for an entity in my app, using the libray jstree. I do what is usual to use it:show an &lt;ul&gt; &amp; &lt;li&gt; structure as usual then i apply the .jstree(&#8230;) function to the parent &lt;div&gt; of the structure.I&#8217;m sorry but i can&#8217;t provide you my source code because is dynamically generated from diferent parts of the app, but i can show a result example of the &lt;ul&gt;&amp;&lt;li&gt; structure:&lt;div id=&#8221;unidadtree&#8221;&gt; &lt;ul&gt;&lt;li id=182 &gt;&lt;a href=&#8221;-ce<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/764fc6b6fd811f357acb575a2046dbc6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser113716<br \/>\njquery clone<br \/>\nClick on a link, then I&#8217;d like to execute an animation after cloning an element. But I&#8217;ve unexpected results. To test : http:\/\/jsfiddle.net\/r4BVb\/3\/On multiple link click (like a geek), clone is proceed many times.$(&#8216;#clone&#8217;).click(function(){$(&#8216;.view_right&#8217;).clone().prependTo(&#8216;.overflowed&#8217;);$(&#8216;.view_right:last&#8217;).css(&#8216;display&#8217;, &#8216;none&#8217;);$(&#8216;.view_right:first&#8217;).hide(&#8216;slide&#8217;, { direction: &#8216;left&#8217; }, 300, function() {$(&#8216;.view_right:last&#8217;).show(&#8216;slide&#8217;, { direction: &#8216;right&#8217; }, 300, function() {$(&#8216;.view<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/9fpLa.jpg?s=32&amp;g=1\" \/><br \/>\nDiventato<br \/>\njquery string slider identifier<br \/>\nIE g gives me the following error:Line: 79 Char: 4 Error: Unexpected identifier, string or number Code: 0The website is test.hatc.org.I am using a template that features fading images, opacity and sliding menus. I saw an error pertaining to jquery.min.js in a browser running IE8 with compatibility mode on, so I think it has something to do with that.Any ideas or similar errors found by anyone?Thanks.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/250a64dfd188523e3bc345273d7574d7?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsupri<br \/>\njavascript jquery jsp backbone.js backbone-views<br \/>\nI am trying to execute jsp code from my backbone view. I am calling server side api from my Html as followsindex.jsp (sample.js is included in this jsp)%@ page contentType=&#8221;text\/html;charset=UTF-8&#8243;import=&#8221;foo.*,java.util.List&#8221;%&gt; &lt;%Foo foo = new Foo();List&lt;XYZ&gt; xyzList = foo.getList();%&gt;I am using backbone framework. My js code is as below.sample.jsSampleView = Backbone.ModalView.extend({name: &#8220;SampleView&#8221;,model: SomeModel,templateHtml : &#8220;&lt;div &gt;&lt;span&gt;Search &lt;\/span&gt;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c7715e765817254e0534f89a4092c0aa?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nExplosion Pills<br \/>\njquery contact-form<br \/>\nI have a contact form I&#8217;m using, I&#8217;m loading it into my website using jquery load, you can see it here when you click contact: www.klossal.comThe problem happens when ever the form tries to notify you about something, whether it&#8217;s that your e-mail is sent or that you forgot to put in your name. I&#8217;m newer to php and jquery so I&#8217;m not exactly sure how to prevent this from happening. These reloads don&#8217;t seem to happen when they happen on the original page www.klossal.com\/contact.php. It seems li<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fc62b586b7a6e298551ac69188390bb8?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\njcolebrand<br \/>\njquery html json<br \/>\nIm parseing a JSON file and add the data to a HTML dropdown , code as follows, $.getJSON(&#8220;http:\/\/mobile.icta.lk\/services\/railwayservice\/getAllLines.php?lang=en&amp;jsoncallback=?&#8221;,function(data) {var $s = $(&#8216;.txtline&#8217;).empty();\/\/ the actual contents of this loop will be\/\/ specific to the datafor (var k in data) {$(&#8216;&lt;option&gt;&lt;\/option&gt;&#8217;).val(data[k].value).text(data[k].text).appendTo($s);}} )Im getting a error as,Resource interpreted as Script but transferred with MIME type application<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4f3f31e18fec155a79d0c29055badbc1?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ndsuser<br \/>\njquery jquery-ui internet-explorer<br \/>\nI have a big problem with IE8 where I use the jQuery framework.What works on Firefox, it doesn&#8217;t work as well in IE8. I am not even checking IE7 :).Basically, I have simple animations that show\/hide div layers and also that move top\/down &#8211; left\/right some of the div layers. Nothing special, just adding some movement to the page. So when you click on contact, instead of the navigation moving up and showing the contact, the contact moves down and breaks the layout which is not so big problem, but<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e40b79eb8e0b193f1de0c75ca89f2ee5?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nkylex<br \/>\njquery<br \/>\nHere is the HTML:&lt;ul&gt;&lt;li&gt;This should fire&lt;\/li&gt;&lt;li&gt;This should not fire, but does &lt;div class=&#8221;delete&#8221;&gt;Delete&lt;\/div&gt;&lt;\/li&gt;&lt;li class=&#8221;load&#8221;&gt;This does not fire as expected&lt;\/li&gt; &lt;\/ul&gt;Here is the jQuery$(&#8216;ul&#8217;).on(&#8216;click&#8217;, &#8216;li:not(.load):not(:has(.delete))&#8217;, function() {alert(&#8216;fire&#8217;); });Any idea how I can prevent the jQuery from firing when the li has a child element with class .delete?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e6670d9f8269155edeb60d394c510006?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAlan A<br \/>\njquery arrays url<br \/>\nI am trying to pass an array via the data var of an href link:&lt;a href=&#8221;#&#8221; class=&#8221;edit&#8221; data-myvar=&#8221;&lt;?php echo json_encode($row); ?&gt;&#8221;&gt;Test&lt;\/a&gt;I am using Jquery to process the variable:$(function(){$(&#8216;.edit&#8217;).click(function(){var res=jQuery.parseJSON($(this).data(&#8220;myvar&#8221;));console.log(res);});});The console log says: Uncaught SyntaxError: Unexpected end of input Any ideas?Thanks.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/64d3d14cad6a8df698836653707e6563?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSourabh<br \/>\njavascript jquery<br \/>\nI read somewhere that best way to use jQuery in JavaScript is to make a self-invoking-anonymous-function an pass it jQuery like this:( function ($) {&#8230; }) (jQuery);This way, $ can also be used for other things in other-functions (like MooTools)But how do I pass jQuery to other functions safely?For instance, this doesn&#8217;t work:( function ($) {i_too_can_use_jquery(&#8216;simple_string&#8217;)l }) (jQuery);function i_too_can_use_jquery (aString, $=jQuery) { \/\/ causes error :(&#8230;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a0857db300da41fcc44d98339816aea3?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser1557970<br \/>\nphp mysql json codeigniter getjson<br \/>\nI have developed a function in my Codeigniter web site, to request data through an API call to retrieve timeline data stored in a mysql table. My json respond is not coming out correctly. I need to create a json response to a $.getJSON, I done this in php . Below is the code that I wrote to get data from mysql and create a json response.public function index_get() {$rs = mysql_query(&#8220;SELECT headline, type, text, media, credit, caption FROM media&#8221;); $timeline = &#8216;{ &#8220;@headline&#8221;: &#8220;&#8216; . $row[ &#8216;headlin<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/0Tg2w.jpg?s=32&amp;g=1\" \/><br \/>\nULLAS MOHAN.V<br \/>\njson jquery-ajax url jquery-mobile cordova<br \/>\nAm working in jQueryMobile and PhoneGap. Currently am facing an issue that; For get the details in JSON format ; I post parameters into an URL (URL1) and I get the JSON response from another URL (URL2) Currently i cant access the JSON data from the second URL.My code is ; function proceed_payment(){ var cardholder_= $(&#8216;#input_Cardholder_name_&#8217;).val(); var card_num_ = $(&#8216;#input_CreditCard_&#8217;).val(); var payment_ =$(&#8216;#card_type_&#8217;).val(); var cvv2_=$(&#8216;#input_cvv2_&#8217;).val(); var url;url=&#8217;https:\/\/www.s<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fc62b586b7a6e298551ac69188390bb8?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\njcolebrand<br \/>\njquery html json<br \/>\nIm parseing a JSON file and add the data to a HTML dropdown , code as follows, $.getJSON(&#8220;http:\/\/mobile.icta.lk\/services\/railwayservice\/getAllLines.php?lang=en&amp;jsoncallback=?&#8221;,function(data) {var $s = $(&#8216;.txtline&#8217;).empty();\/\/ the actual contents of this loop will be\/\/ specific to the datafor (var k in data) {$(&#8216;&lt;option&gt;&lt;\/option&gt;&#8217;).val(data[k].value).text(data[k].text).appendTo($s);}} )Im getting a error as,Resource interpreted as Script but transferred with MIME type application<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b1a95a98c108488de4d890e14ce7c279?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSteve<br \/>\njavascript json<br \/>\nI have simple JSON that I need to parse to object. Strangely it doesn&#8217;t work even though if I copy and paste my JSON string to JSONLint (http:\/\/jsonlint.com\/) it will show that it&#8217;s valid.var string = &#8216;{&#8220;token&#8221;:&#8221;9eebcdc435686459c0e0faac854997f3&#8243;,&#8221;email&#8221;:&#8221;201403050007950&#8243;,&#8221;id&#8221;:&#8221;13&#8243;,&#8221;updated_at&#8221;:&#8221;2014-03-05 10:34:51&#8243;,&#8221;messageguides&#8221;:&#8221;[{\\&#8221;name\\&#8221;:\\&#8221;Un-named Messaging Guide 1\\&#8221;,\\&#8221;pages\\&#8221;:[\\&#8221;sustainabilitydirectors\\&#8221;,\\&#8221;marketingnbusinessdevelopmentdirectors\\&#8221;],\\&#8221;date\\&#8221;:1394015692958}]&#8221;}&#8217;;var obj = JSO<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b41c60896e56d576b08bfc8739c4e493?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDCHP<br \/>\njson parsing<br \/>\nHi all i am trying to setup a json feed. i have been working from the following urlhttp:\/\/rest.users34.interdns.co.uk\/index.php?format=jsonthis then outputs the json.http:\/\/jsonlint.com\/but i cant grab the feed via jquery json like belowhttp:\/\/jsfiddle.net\/isimpledesign\/NTdBp\/im getting this error1Uncaught SyntaxError: Unexpected token :<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/429aa23a05c8601d45816e6a613ec574?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSebastian<br \/>\nios objective-c json uitableview<br \/>\nAs the question says, I get an unexpected output when importing JSON into a TableView class.JSON:{&#8220;city&#8221;:&#8221;Cambridge&#8221;}{&#8220;city&#8221;:&#8221;Oxford&#8221;}Objective-C:NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@&#8221;http:\/\/www.domain.com\/cities.php&#8221;]]; NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSLog(@&#8221;%@&#8221;, response);Output:&lt;7b226369 7479223a 2243616d 62726964 6765227d 7b226369 7479223a 224f7866 6f726422 7d&gt;Fairly sure I&#8217;m str<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/aa56a00a9f9ee1f6a72376071da280f0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSt\u00e9phane Bruckert<br \/>\njquery ajax json facebook facebook-graph-api<br \/>\nThis is my first time using Facebook in jQuery.I&#8217;m getting the following error:Uncaught SyntaxError: Unexpected token : www.facebook.com\/feeds\/page.php?id=20531316728&amp;format=JSON&amp;callback=jQuery110105899784066714346_1383828332964&amp;_=1383828332965:2Code$.ajax({url: &#8216;http:\/\/www.facebook.com\/feeds\/page.php?id=20531316728&amp;format=JSON&#8217;,dataType: &#8216;jsonp&#8217; }).done(function(data) {alert(data); });JSFiddleWhy am I getting this?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1f119998a83f15dad37d73594071d739?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nbrandonjschwartz<br \/>\njson bower<br \/>\nI have the latest version of Bower installed. I am trying the command bower register flatly-3 https:\/\/github.com\/brandonjschwartz\/bower-bootswatch-flatly.gitBower has the error message that the bower.json file is malformed due to an unexpected string. I have tried a number of different things (punctuation etc) but get the same error&#8230; Any help is greatly appreciated<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/907cc81cee2d467e21015b7efbe3440a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\n0xAX<br \/>\njavascript json<br \/>\nI got following json from services:{Key1 : &#8220;val1&#8221;, Key2 : &#8220;val2&#8221;}I need to convery Key1 to the &#8220;Key1&#8221; and Key2 to the &#8220;Key2&#8221;, because i want to JSON.stringify this object, but it gives error when keys not strings.How to convert object&#8217;s keys to string?UPD Yes, sorry, {Key1 : &#8220;val1&#8221;, Key2 : &#8220;val2&#8221;} works, but i have sometimes keys with &#8211; symbol, like {Key-1 : &#8220;val1&#8221;} and got Unexpected token in this case.Thank you.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f1d5ca7939336d416f1d907cac20f1ba?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\njlordo<br \/>\njava json gson<br \/>\nHow can I parse this json via Gson?Here is my PodModel.class And this is my for retrieve the json.This is the gson part.gson = new Gson();PodsModel pods = gson.fromJson(builder.toString(), PodsModel.class);System.out.println(pods.getPods().getDomain());Logcat returns with this: logcat-output<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Andreu Heineken javascript jquery symfony1 jstree i did a descendant tree for an entity in my app, using the libray jstree. I do what is usual to use it:show an &lt;ul&gt; &amp; &lt;li&gt; structure as usual then i apply the .jstree(&#8230;) function to the parent &lt;div&gt; of the structure.I&#8217;m sorry but i can&#8217;t provide you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2974","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2974","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2974"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2974\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2974"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2974"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2974"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}