UPDATED QUESTION
Let i have a blank page with only a simple ajax request as follow
My Ajax Call is
$.ajax({
url: "ajax/ajax-latest-lead.php",
method: "POST",
data: {
cityVal: cityVal
},
cache: false,
async: true,
timeout: 2000, //Set your timeout value in milliseconds or 0 for unlimited
success: function(data) {
alert(data);
},
error: function(jqXHR, textStatus, errorThrown) {
if (textStatus === "timeout") {
alert("Call has timed out"); //Handle the timeout
} else {
alert("Another error was returned"); //Handle other error type
}
}
});
It will Always Going to Call has timed out.and waiting time is 2.0 Seconds in mozila firefox->network tab
And A Php File is as follow
<?php
include("../include/database.php");
if(!empty($_POST['cityVal']))
{
$cityVal = $_POST['cityVal'];
echo $cityVal;
}
?>
Problem is When i am including Database file The Response time of ajax is 3.0 seconds. and when i am excluding database file alert(data)
runs immediately.
Database.php
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$conn = new mysqli("$host","$username","$password","$db_name");
I tried Followings
e.preventDefault();
cache: false,
async: false,
beforeSend:function(data){
alert("sending");
},
Before Send Alert Will be shown immediately
I am stuck here very badly. please help to find this out.