我正在使用cakePHP 3.0,并在使用ajax时遇到问题。事实上,我想执行的操作我的阵列控制器上的“SpecimensController”从我的观点来的“viewTab”“标本”CakePHP - 如何将URL传递给ajax?
<script type="text/javascript" >
var tab = new Array();
function updateResult(){
$.ajax({
type:"POST",
url:"<?php echo Router::url(array('controller'=>'specimens','action'=>'index'));?>",
data:{datas: $("select[name='filtreVariable\\[\\]']").map(function(){return $(this).val();}).get()},
dataType: 'text',
async:false,
success: function(data){
alert('success');
},
error: function (data) {
alert("error");
}
});
}
$("#filtre").submit(function(){
updateResult();
});
</script>
行动“viewTab”只是做:
echo "success";
但我无法找到正确的URL,因此可以调用函数成功。我尝试了很多东西,并且总是有被调用的ajax的函数错误。 :/
尝试调试像'错误:功能(jqXHR,textStatus,errorThrown){警报( 'errorThrown')};' –
你是什么意思约“但是我无法找到正确的URL,因此可以调用函数成功。” ?你找不到哪个网址? – Sojtin
[Ajax not calling success function]可能的重复(http://stackoverflow.com/questions/30002886/ajax-not-calling-success-function) – ndm