How to use the ajax() function in JQuery?
<p>In my javascript file I have the following:</p>

<pre><code>&lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;

$.ajax({

    type: 'post',
    url: 'script.php',
    data: '',
    success: function(output) {
        alert(output[0])
    }

});

&lt;/script&gt;
</code></pre>

<p>In my PHP file I have the following:</p>

<pre><code>&lt;?php

echo 'dog';
echo 'cat';

?&gt;
</code></pre>

<p>Now I know I'm not passing any data through the ajax function, I just wrote the above to test one thing, that is:</p>

<p>When I alert <code>output[0]</code> I get the letter "d". Instead I want to be able to get "dog" and when I alert <code>output[1]</code> I want to be able to get "cat". How to achieve this?</p>
