This is making no sense at all.
I've tried to work the code on my web platform and also from my computer.
Here is my checklist.
1) Port 3306 is open for mySQL.
2) Code minimized as shown below.
3) Used an online PHP code tester to see if there are any errors.
4) Used Document.ready and called the method with the ajax call.
5) Used an alert to test if my html contained any errors.
6) Checked the file permissions
7) mysqli
Here is the code:
PHP
<?php
include 'pass.php';
//ini_set('max_execution_time', 4000);
ini_set('memory_limit', '16M');
try {
$con = mysqli_connect($host, $username, $password, $db_name, $port);
if (mysqli_connect_error()) {
echo 'Could not connect to database';
}
echo 'hello';
}
catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "
";
}
mysqli_close($con);
?>
AJAX
function getExample() {
alert("test");
$.ajax({
type: "GET",
url: "code/getExample.php",
dataType: "html",
cache: false,
success: function(response) {
alert(response);
}
});
}
The alert test is showing on my webpage so no errors so far and the file permissions except for pass is read and write and execute.
From your experience, whats going wrong?
Note: I dont want to send data and eventually I want to retrieve it as json but for the time being Im testing with dataType: 'html',.
I'm expecting hello to appear as an alert but nothing appears only alerts test before the ajax call. ( in reply to comment)
* EDIT *
403 forbidden error... when I set my pass file to read only it resets to read and write... it looks like changing the file permissions does not work.