Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting JSON data from external website
    primarykey
    data
    text
    <p>I'm trying to get JSON data from a website using the following code, but I get the error Uncaught SyntaxError: Unexpected identifier at file:///android_asset/www/projectName.html:1 If I save the data from the website as a .json file I can access it fine, but not if I access it from the website. How do I make this work from the website?</p> <p>HTML:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt; &lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $("button").click(function(){ $.get('http://example.ca/log_sheets.json', function(data) { alert('get performed'); var obj = eval ("(" + data + ")"); $("p").html(obj[0].log_sheet.activity_type); }); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h2&gt;Heading&lt;/h2&gt; &lt;p&gt;Display&lt;/p&gt; &lt;button&gt;Click me&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Sample of JSON data:</p> <pre><code>[{"log_sheet":{"activity_type":"Normal","activity_value":null,"carbs_value":25.0, ect... }}] </code></pre> <p>Code to run html page with phonegap:</p> <pre><code>package com.example.projectName; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.MenuItem; import android.support.v4.app.NavUtils; import org.apache.cordova.*; public class MainActivity extends DroidGap { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.loadUrl("file:///android_asset/www/projectName.html"); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } } </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