大家好,我想揭示一个问题...我的网络应用存在这种情况:
//路线
getRoute()->post('/aggiungiMateria', array("GestioneController","aggiungiMateria"));
// CONTROLLER
function aggiungiMateria(){
try{
$model = new GestioneModel();
$alunno = $model->aggiungiMateria();
echo 'ok';
}catch(Exception $e){
echo json_encode(array($e->getMessage()));
}
}
//模型
function aggiungiMateria(){
$nome = addslashes($_POST['nome']);
try{
$db = $this->getConnection();
$query = $db->prepare("INSERT INTO materie SET nome = '$nome' ");
$query->execute();
}catch(PDOException $e){
echo $e->getMessage();
}
}
// HTML
<label>Materia</label>
<input type="text" id="nome" value="<?php echo $materia;?>" />
<input type="hidden" id="controllo" value="<?php echo $id?>"/>
<button onclick="gestione();">SALVA</button>
// JS AJAX
function gestione(){
$('.loading').show();
var nome = $('#nome').val();
var id = $('#controllo').val();
if(id!=''){
$.post( "../../ws/modificaMateria", { //NOT FOUND
nome:nome,
id:id
},
function( data ) {
if(data=='ok'){
location.href='materie.php';
}
}, "html");
}else{
$.post( "../../ws/aggiungiMateria", { //NOT FOUND
nome:nome,
id:id
},
function( data ) {
if(data=='ok'){
location.href='materie.php';
}
}, "html");
}
}
当单击SALVA按钮时,调试器将/ ws / aggiungiMateria抛出异常,但未出现错误404,而jQuery-2.1.4.min的f.send却使我从chrome dev工具中遇到了未捕获的错误。对于这篇文章中的任何错误,我深表歉意。
有什么建议吗?预先感谢。
答案 0 :(得分:0)
我通过使用AllowOverride All指令修改apache配置文件来解决