I have issue with ajax response. My test php file content looks like:
<?php
$values = array('value'=>'123',
'key'=>'Test'
);
echo json_encode($values);
?>
And everything works perfectly. But problem is when I try but include database connection file then response stops.
Basically if I add require_once 'database.php';
Connection file content:
<?php
$login = new PDO("sqlsrv:Server=SERVER;Database=db", "login", "pass");
?>
I already tried with
ini_set('display_errors', 1);
error_reporting(E_ALL);
but nothing. This connection is fine, file location is fine as well. And working with another website.
test.php file content:
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
require_once 'database.php';
$values = array('value'=>'123',
'key'=>'test');
echo json_encode($values);
?>
file database.php in right location.
Please go step by step:-
1.) First of all you need to run your test.php file directly to ensure that there are no errors or warnings.
2.) If the file runs and echos the json data perfectly(without any warnings or errors), only then run the ajax call to get the response.
3.) You will certainly get the response.if not,then the problem might in your ajax function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With