In my javascript file I have the following:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
$.ajax({
type: 'post',
url: 'script.php',
data: '',
success: function(output) {
alert(output[0])
}
});
</script>
In my PHP file I have the following:
<?php
echo 'dog';
echo 'cat';
?>
Now I know I'm not passing any data through the ajax function, I just wrote the above to test one thing, that is:
When I alert output[0] I get the letter "d". Instead I want to be able to get "dog" and when I alert output[1] I want to be able to get "cat". How to achieve this?