ajax POST respond
<p>I use niceEdit as a html editor and a mysql for back end. The process I will send the data into a php using AJAX.</p>

<p>Heres my html code:</p>

<pre><code>&lt;div class='atabcontent'&gt;
    &lt;form id='apostform' method='POST'&gt;
        &lt;input name='request' type='hidden' value='atabaddnew' /&gt;
        &lt;textarea id='aposttextarea' name='area1' style='width:780px; height: 400px; margin: 10px auto 0 auto;'cols='40'&gt;&lt;/textarea&gt;
    &lt;div style='height: 5px;'&gt;&lt;/div&gt;
    &lt;button id='apostsubmit'&gt;Save&lt;/button&gt;
    &lt;/form&gt;
&lt;/div&gt;
</code></pre>

<p>and heres the ajax code.</p>

<pre><code>$("#apostform").submit( function () { 
    //add a loading bar first
    $('div.atabcontent').append("&lt;img class='loading' src='media/loading.gif' /&gt;");
    //send data to processor.php
    $.post(
        'processor.php',
        $(this).serialize(),
        //here, where we're going to manage the respond from the processor.php
        function(data){
            //remove the loading bar
            $('.atabcontent img.loading').remove();
            //output the respond
            $('div.atabcontent').html(data).show();
        });
    return false;   
});
</code></pre>

<p>and heres the php file (processor.php).</p>

<pre><code>&lt;? //this a processor e.g. post, delete, edit etc..
    //check if a post "request" is present..
    if (isset($_POST['request']))
    {
        //check if what type of request, if request type is equal to atabmenu then..
        if ($_POST['request'] === "atabmenu")
        {
            echo $_POST['data'];
        }
        elseif ($_POST['request'] === "atabaddnew")
        {
            echo htmlspecialchars($_POST['area1']);
        }
        //end
        //else if no request then go to fail.php along with the error code of "unable to     process the data"
    }
    else
    {
        header("location: fail.php?error=unable to process the data");
    }

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

<p>as you can see on the above code, it should work fine, but the respond from the php file that has been fetch by the ajax respond handler is empty and seems like there is no data that has been sent or neither has been received also i tried this</p>

<pre><code>$("#apostform").submit( function () { 
    var data = $('#apostform textarea').val();

    alert (data);
    return false;   
});
</code></pre>

<p>but there the alertbox content is empty and as you can see in the code, it should alert a box with the value of the "#apostform". I tried a normal form, i mean no ajax and its work fine because i can see the data has been receive because it display the data receive from the form.</p>

<p>hope someone could help me on pointing out on what seems the problem on this. anyway i use niceEdit textbox <a href="http://nicedit.com/" rel="nofollow">http://nicedit.com/</a></p>

<p>PS: im open in any suggestion, recommendation and idea. Thanks in advance.</p>
