为什么从AJAX返回的值几乎立即消失?

this is my server-side code:

modify_emp.php

<?php
    echo $_POST[id];
?>

And this is my Javascript in my html page:

<script>

  $(document).ready(function () {

  var alreadyClicked = false;

  $('.element').hover( 
    //mouseenter function
    function(){
        $('.element').click(
            function(){
            $(this).css("color","blue");
            var objName = $(this).attr('name');
            var objColumn = $(this).attr('id');
            if(!alreadyClicked){
                alreadyClicked = true;
                $(this)
                .prepend('<form method="POST" class="newInput"><input type="text" name="newInput" style="width:140px"></input></form>');
                var elemento = $(".newInput");
                var position = elemento.position();
                $(".newInput").css({
                    'position': 'absolute',
                    'top': position.top + 15,
                    'opacity':0.9,
                    'z-index':5000,
                })
                .focus();
                //on enter keypress
                $(document).keypress(function(e) {
                    if(e.which == 13) {

                        $.ajax({

                            url: 'modify_imp.php',
                            type: 'post',
                            data: { id : objName, column : objColumn },
                            success: function(data, status){
                                $("#debug").html(data);
                            }

                        });
                    }
                });
             } //if (!alreadyClicked) end
        }); //end mouseenter function
   },
   //mouseleave function
   function () {
    alreadyClicked = false;
    $(this).css("color","red");
    $(".newInput").remove();
   }
 ); //end .hover

});

The debug is a <div id="debug"> </div> at the end of my html page where i want to show my response from server. When i press 'ENTER' I can actually see the value for 0.1s inside that div, but then it disappears.

I already tried to pass the return value to a local or global variable but it didn't work. For some reason the value inside response is lost after 0.1s, even if i pass it to another variable elsewhere.

Can someone explain me why and how can i "store" the server response?

EDIT: Just edited with my entire <script>

Since you see the result momentarily, I'm going to hazard a guess that you have a form element on your page and when you hit return, it's actually submitting the form. You briefly see the result of the ajax operation and then your form submits causing the page to reload as a new blank page. This is a common issue and always has these same symptoms.

You can either remove the form element or block the default submission of the form with javascript.

If you show us more of your actual HTML, we could help more specifically with how to prevent the form from submitting.

Another way would be to assign a BUTTON to trigger the ajax, and set the button outside of the FORM

You can solve this by calling the function in the form tag i.e,

<form action="javascript:AnyFunction();">

your code goes here

.