我已经看了一段时间,我认为主要问题是我引用的文件,但我不确定。我正在处理散布在整个项目文件夹中的大量php文件,但是在我正在处理文件NavBar.php的文件中,我在layout.php中使用require()语句调用它 这里是我遇到问题的代码(顺便说一句,所有这些代码都在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
}
}
?>
我知道sql调用已经过时了,我应该把它更改为PDO我会在我弄清楚为什么AJAX不能正常工作时立即进行切换。这个php代码进行db调用并检索一些显示在li中的数据(为表中的每一行生成的新li)(下拉列表),当用户单击它时,我想使用此JS函数来保存单击的索引li到php变量(因此AJAX,我对AJAX很新,所以我很难搞清楚):
<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>
我认为主要问题可能是我引用的文件,因为layout.phtml引用了NavBar.php,这可能是层次结构中某些其他文档所需要的。当我点击li:
时,这是我在控制台中遇到的错误jquery.min.js:4 XHR完成加载:POST&#34; http://localhost/shiprequest/layout.phtml&#34; .send @jquery.min.js:4ajax @jquery.min.js:4(匿名函数) @ shiprequest?lang = en:235dispatch @ jquery.min.js:3r.handle @jquery.min.js:3 shiprequest?lang = zh:240
(!)致命错误:未捕获的异常&#39; Zend_Acl_Exception&#39;消息&#39;资源&#39; shiprequest_layout.phtml&#39;找不到&#39;在 364 的C:\ sgm \ library \ Zend \ Acl.php中 (!)Zend_Acl_Exception:Resource&#39; shiprequest_layout.phtml&#39;在 364 的C:\ sgm \ library \ Zend \ Acl.php中找不到 调用堆栈 #TimeMemoryFunctionLocation 10.0006145888 {main}().. \ index.php : 0 20.0018168016require_once(&#39; C:\ sgm \ application \ bootstrap.php&#39;).. \ index.php : 5 30.11182860576Zend_Controller_Front-&gt; dispatch().. \ bootstrap.php : 124
答案 0 :(得分:0)
根据您提供的邮件错误:
未捕获的异常&#39; Zend_Acl_Exception&#39;与消息&#39;资源 &#39; shiprequest_layout.phtml&#39;找不到
验证shiprequest_layout.phtml是否存在。 你可能想写shiprequest_layout.html而不是.phtml
<script>
$(document).on('click', '.list_item', function() {
var indx = $(this).index();
$.ajax({ // add ajax code here
type: 'POST',
url: 'layout.html', <------ here
data: {pat_id: indx}, // send parameter like this
success: function(response) {
console.log(response);
}
});
});
</script>
来自评论的编辑:
如果你的文件确实是layout.phtml,那么你的错误就在file Acl.php (C:\sgm\library\Zend\Acl.php) at line 364
。第364行试图找到shiprequest_layout.phtml
如果此文件不存在,您将收到此错误。
您可能需要layout.phtml
而不是shiprequest_layout.phtml