AJAX脚本崩溃浏览器

Im trying to submit user register information with AJAX like this:

<script>

$("#submit_btn").click(function() {
event.preventDefault();
var supplied_username = $('#desired_username').val();
var password = $('#password').val();
var email_address = $('#email_address').val();



$.post("register", { desired_username: desired_username, password: password, email_address: email_address } ,
function(data){
    $('body').append(data);
});
});
</script>

The return data is simply a string of text (i.e. Success! or Register problem....). I think that the script must be infinitely looping somehow but Im not sure where or why. The backend works perfectly when I pass normal POST data to it without AJAX. That is why I think it must be a problem with the client side. Any ideas what could be going on here?

wouldn't it be better to append it within a proper text tag (<p> or anything else) and inside the document, instead of the body directly?

I once tried running AJAX on client-side with no succes, then tried the same code server-side with success. May that be the case?

Also, if I looked correctly, you're passing wrong variables. You create a supplied_username and pass a desired_username. May that not be the problem?

I think you've left out some stuff. I think the code below is what you're looking for

<script>

$("#submit_btn").click(function(event) {
     event.preventDefault();
     var supplied_username = $('#desired_username').val();
     var password = $('#password').val();
     var email_address = $('#email_address').val();



    $.post("register", { desired_username: supplied_username, password: password, email_address: email_address } , function(data){
           $('body').append(data);
    });
});
</script>