Read a GeoJSON file and a text file with jQuery.get() method
<p>I want to read a txt file, which contains geoJSON string. The example of a single line in the file is below:</p>

<pre><code> {"type":"Feature","properties":{"mag":1.8,"place":"4km E of Aromas, California","time":"1365112523900","updated":"1365112626531","tz":-420,"url":"http://earthquake.usgs.gov/earthquakes/eventpage/nc71966380","felt":null,"cdi":null,"mmi":null,"alert":null,"status":"AUTOMATIC","tsunami":null,"sig":"50","net":"nc","code":"71966380","ids":",nc71966380,","sources":",nc,","types":",general-link,geoserve,nearby-cities,origin,tectonic-summary,","nst":null,"dmin":"0.07186522","rms":"0.27","gap":"43.2","magnitudeType":"Md"},"geometry":{"type":"Point","coordinates":[-121.5957,36.885,1.5]},"id":"nc71966380"}
</code></pre>

<p>A simple program to verify if I can read the file is:</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt;
    $.get('test.txt', function(data) {

        var line = data.split("\n");
        $('body').append('&lt;div&gt;' + line + '&lt;/div&gt;');
    });

&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;/body&gt; 
&lt;/html&gt;
</code></pre>

<p>However, I got this error:</p>

<pre><code> Timestamp: 04/04/2013 10:52:40 PM
 Error: not well-formed
 Source File: file:///home/abc/test.txt
 Line: 1, Column: 1
 Source Code:......
</code></pre>

<p>I attempted to read a simple "hello" string in another file but I got a syntax error.</p>

<p>Two questions please, How can I read the GeoJSON string from the file? How can I read a simple text file line by line?</p>

<p>My browser is firefox v19.0.2</p>

<p><strong>SOLUTION</strong></p>

<p>This is the script that solved the problem:</p>

<pre><code>$.ajax({
type: 'GET',
url: 'http://earthquake.usgs.gov/earthquakes/feed/geojsonp/1.0/hour',
async: false,
jsonpCallback: 'eqfeed_callback',
dataType: 'jsonp',
success: function(json) {
   alert(json.features[2].properties.mag);
},
error: function(e) {
   console.log(e.message);
}
});
</code></pre>
