i have a php file in life ray for ajax
<?php
//connect to the mysql
$db = @mysql_connect('127.0.0.1', 'root', 'root') or die("Could not connect database");
@mysql_select_db('liferaydb', $db) or die("Could not select database");
//database query
$sql = @mysql_query("select name, status from gb_guestbook");
$rows = array();
while($r = mysql_fetch_assoc($sql)) {
$rows[] = $r;
}
//echo result as json
echo json_encode($rows);
?>
However as i placed the file under \tomcat-8.0.32\webapps\ROOT and attempted to go to this url: http://localhost:8080/server_processing.php, it says the requested resources could not be found..
However, when i placed a index.jsp inside the same directory after starting the tomcat server, i am able to access it locally. Please advise.
This is my ajax code:
$(document).ready(function() {
$("#ajaxButton").click(function() {
$.ajax({
type: "Post",
url: "\\server_processing.php",
success: function(data) {
var obj = $.parseJSON(data);
var result = "<ul>"
$.each(obj, function() {
result = result + "<li>Name : " + this['name'] + " , Status : " + this['status'] + "</li>";
});
result = result + "</ul>"
$("#result").html(result);