I've been looking at this for a while and I think the major issue is the file i am referencing but I am not sure. I am working with a large amount of php files scattered all over the project folder but in the immediate folder I am working with files NavBar.php which is called using a require() statement in layout.php here's the code I am having trouble with (btw all of this code is in NavBar.php):
<?php
$db=mysql_connect('localhost','root','');
if(!$db) {
die('Could not connect: '.mysql_error());
}
$connection_string=mysql_select_db('shipreq_stagetest',$db);
$selectSQL='SELECT * FROM color_patterns';
$queryset=mysql_query($selectSQL);
$num=mysql_num_rows($queryset);
if(0==$num) {
echo "No record";
exit;
} else {
while($row=mysql_fetch_assoc($queryset)) {?>
<li class= "list_item" onclick="<?php $indx = $_POST['pat_id'];?>">
<?php echo($row['name']);?></li><?php
}
}
?>
I know the sql calls are outdate and I should change it to PDOs I will make the switch as soon as I can figure out why the AJAX isn't working. this php code makes a db call and retrieves some data which displayed in the li (new li generated for each row in the table)(dropdown) and when a user clicks it I want to use this JS function to save the index of the clicked li to a php variable (hence the AJAX, I am really new to AJAX so I am having trouble figuring it out):
<script>
$(document).on('click', '.list_item', function() {
var indx = $(this).index();
$.ajax({ // add ajax code here
type: 'POST',
url: 'layout.phtml',
data: {pat_id: indx}, // send parameter like this
success: function(response) {
console.log(response);
}
});
});
</script>
I think the major issue might be the file I am referencing since NavBar.php is referenced by layout.phtml which is probably required by some other document in the hierarchy. this is the error I get in the console when I click on the li:
jquery.min.js:4 XHR finished loading: POST "http://localhost/shiprequest/layout.phtml".send @ jquery.min.js:4ajax @ jquery.min.js:4(anonymous function) @ shiprequest?lang=en:235dispatch @ jquery.min.js:3r.handle @ jquery.min.js:3 shiprequest?lang=en:240
( ! ) Fatal error: Uncaught exception 'Zend_Acl_Exception' with message 'Resource 'shiprequest_layout.phtml' not found' in C:\sgm\library\Zend\Acl.php on line 364 ( ! ) Zend_Acl_Exception: Resource 'shiprequest_layout.phtml' not found in C:\sgm\library\Zend\Acl.php on line 364 Call Stack #TimeMemoryFunctionLocation 10.0006145888{main}( )..\index.php:0 20.0018168016require_once( 'C:\sgm\application\bootstrap.php' )..\index.php:5 30.11182860576Zend_Controller_Front->dispatch( )..\bootstrap.php:124