Not getting return data from PHP script in JQuery
<p>I'm learning how to integrate JQuery, AJAX and PHP together.</p>

<p>My problem is that my success function isn't getting any value from the parameter and just getting a '0'. I'm not really sure what I'm doing wrong either, but I have just been following this tutorial <a href="http://blog.themeforest.net/tutorials/jquery-for-absolute-beginners-day-15-part-2/" rel="nofollow">JQuery &amp; PHP Tutorial</a> and just copied how he got the value from the PHP code using echoes and a parameter variable r.</p>

<p>I have tried searching for the solution, but I'm not sure if any of the results are relevant to what I am doing. I tried following some of their advice but none seems to work (the promise thing for jQuery)</p>

<p>I hope someone can enlighten me what I am doing wrong as I am eager to learn more PHP and jQuery.</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
&lt;script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"&gt;&lt;/script&gt;
&lt;script&gt;
    $(function () {
        jQuery("form").submit(function(e) { 
             var input = $("#input").val();
             var url = 'input=' + input;
             $.ajax({
               type: "POST",
               url: "process.php",
               data: url,
               success: function(r) {
                   $("#output").text(function(r) {
                        return r;
                   });
               }
             });
             e.preventDefault();
        });
    });
&lt;/script&gt;
&lt;title&gt;Insert title here&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form action="process.php" method="post"&gt;
        Inputs:&lt;br /&gt;
        &lt;textarea rows="15" cols="60" id="input" name="input"&gt;Some text...
        &lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;
        Start:
        &lt;input type="text" id="start" name="start" /&gt;
        End:
        &lt;input type="text" id="end" name="end" /&gt;&lt;br /&gt;
        &lt;input type="submit" id="submit" name="submit" value="Submit"&gt;
    &lt;/form&gt;
    &lt;p id="output"&gt;Output: Some Random Text&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>PHP:
    

<pre><code>require 'parser.php';
$parser = new Parser();
#header('index.php');
$hash = $parser-&gt;parse($_POST['input']);
$keys = array_keys($hash);
foreach($keys as $key) {
    echo "$key -&gt;";
    $dests = $hash[$key];
    foreach($dests as $dest) {
        echo " $dest";
    }
    echo "&lt;br /&gt;";
}

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