Ajax请求超时太快

I am calling my php page (test.php) through ajax request, and that test.php contains list of queries under one while loop. When I call that page using ajax it terminates before its maximum execution time (I tried setting max value to max_execution_time, set_time_limit in ini/php file) and gives 500 internal server error.

When I call same test.php using url (and not through ajax request), it works properly.

Please help what might be the cause.

you can try to increase your ajax timeout

jQuery.ajax({
    url: 'phpfile.php',
    success: function (result) {                               
        //
    },
    timeout: 10000
});