Note that there are some explanatory texts on larger screens.

plurals
  1. POConnect JSON in Javascript via field names
    primarykey
    data
    text
    <p>I am trying to connect JSON data into my Javascript and the JSON looks like this:</p> <pre><code>{ "status":"ok", "count":5, "pages":1, "category":{ "id":85, "slug":"front-page-active", "title":"Front Page Active", "description":"", "parent":0, "post_count":5 }, "posts":[{ "id":1535, "type":"post", "slug":"url", "url":"url/", "status":"publish", "title":"title", "title_plain":"title", "content":"content… … </code></pre> <p>My Javscript looks like this:</p> <pre><code>'&lt;p class="listTitle"&gt;' + item.title + '&lt;/p&gt;' </code></pre> <p>I know I am connecting the file properly because I have gotten this to work with other JSON files. I am thinking that this file is setup differently and I just don't know what I am missing. Do I have to modify the item.title call?</p> <p>This is the full javascript file:</p> <pre><code>$(document).ready(function(){ var outputNews = $('#newsPageUl'); var spinner = $('.pageLoaderSpinner'); $.ajax({ url: 'url', dataType: 'json', timeout: 20000, cache: false, success: function(data, status){ $.each(data, function(i,item){ var newsEvent = //Generated HTML '&lt;li&gt;&lt;div class="newsFeedTopBg"&gt;&lt;/div&gt;&lt;div class="newsFeedMidBg"&gt;' + '&lt;p class="listTitle"&gt;' + item.title + '&lt;/p&gt;' // + '&lt;p class="date"&gt;' + item.posts[0].date + '&lt;/p&gt;' // + '&lt;p class="pContent"&gt;' + item.posts[0].content + '&lt;/p&gt;' + '&lt;/div&gt;&lt;div class="newsFeedBottomBg"&gt;&lt;/div&gt;&lt;/li&gt;' //End Generated HTML ; spinner.empty(); outputNews.append(newsEvent); }); }, error: function(){ spinner.empty(); navigator.notification.confirm( "Could not connect.", connectionErrorNews, 'Connection Error', "Go Back, Try Again" ); } }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload