在数据库操作之后,Ajax功能不起作用

Here below my extrafieldscript.php

if($_POST['action'] == 'createField')
    {
        $fetch = mysql_fetch_array(mysql_query("select MAX(id) from extrafields"));

        $id = $fetch[0] + 1;

        mysql_query("insert into extrafields (`id`,`active`,`type`,`name`) values ($id,0,1,'')");

        mysql_query("ALTER TABLE `mitglieder` ADD `adf$id` INT(11) NOT NULL");

        echo 'Inserted';

    }

And my script file is

function createField()
        {

            $.ajax({
                    url : 'extrafieldscript.php',
                    type : 'POST',
                    data : 'action=createField',
                    success : function(data)
                    {
                        alert(data);
                        //location.reload();
                    }
                });
        }

My problem is - before database operation the alert is worked well. But after database page is reloads or nothing response in the page......

How to get "inserted" msg in my alert box after database operations....

advance thanks mates.

The “Inserted” alert actually occurs after the database operation is performed. Ajax handler is called on successful ajax call.

Think of it as of callback (it is the callback.)