点击外部div的ajax php帖子

I want to post something after writing it into a textarea without clicking any button but on clicking outside the textarea..How can I achieve that?? My code...

<form action="javascript:parseResponse();"  id="responseForm">
<textarea align="center" name="post" id="post">Write something</textarea>
<input type="button" id="submit" value="submit" />
</form>

AJAX:

$('#responseForm').submit(function({$('#submit',this).attr('disabled','disabled');});

    function parseResponse(){
    var post_status = $("#post");
    var url = "post_send.php";

    if(post_status.val() != ''){

        $.post(url, { post: post_status.val()}, function(data){
        $(function(){
        $.ajax({
            type: "POST",
            url: "home_load.php",
            data: "getNews=true",
            success:function(r)
    {
        $(".container").html(r)
            },
    })
    })  

        document.getElementById('post').value = "";

    });

        }
    }

I want to remove the button...and when an user clicks outside the textarea it will automatically submit the information...The whole body outside the textarea will act as the submit button...when user writes any info on the textarea...How can I achieve that??

Try the following:

$(document).on("click", function(e) {
    var $target = $("#YOUR_ELEMENT");
    if ($target.has(e.target).length === 0) {
        your_submit_function();
    }
});

You could also attach your submit function to the blur event for improved functionality:

$(document).on("click", function(e) {
    var $target = $("#YOUR_ELEMENT");
    if ($target.has(e.target).length === 0) {
        your_submit_function();
});

$("#YOUR_ELEMENT").on("blur", function() {
    your_submit_function();
});

You can attach a click handler to the entire document, and then cancel the event if the user clicked inside the text area. Something like this might do the trick:

$( document ).on( "click", function( ev ) {
    if( $( ev.target ).index( $( "#post" )) == -1 ) {
    // User clicked outside the text area.
    }
} );

I use code similar to this to accomplish essentially the same thing (check when a user clicked outside of something). This is a copy and paste (slight alterations) of that code, and I haven't tested for your purposes. Essentially, it adds a handler to the entire document for the click event, then only executes the code if the element clicked on was not your textarea.