I'm trying to connect to a php file that is located at http://127.0.0.1:8080/projects/mssql/index.php with jquery's ajax method but I'm unable to get a response. What am I doing wrong?
I'm doing all of this local - do I have to change any settings in my php.ini file or is there an error in the code? Please help
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
alert("hoi");
$.ajax({url: "http://127.0.0.1:8080/projects/mssql/index.php", async: false, success: function(result){
$("div").html(result);
}});
});
});
</script>
</head>
<body>
<div><h2>Let AJAX change this text</h2></div>
<button>Change Content</button>
</body>
</html>
This is the php file. the php file itself works because I do get the expected response when I type it's location in my browser
<?php
$serverName = "PAUL\SQLSERVER";
$connectionInfo=$arrayName = array('Database' => "TestDatabase" );
$conn = sqlsrv_connect($serverName,$connectionInfo);
if($conn){
echo "connection established";
}
else{
echo "connection failure";
die(print_r(sqlsrv_errors(),TRUE));
}
$sql="select custID from customer";
$stmt = sqlsrv_query($conn,$sql);
if($stmt == false){
echo "Error retriving data";
die(print_r(sqlsrv_errors(),TRUE));
}
echo "<br>";
$row = sqlsrv_fetch_array($stmt);
echo $row["custID"];
?>