jquery - Ajax 动态选择框 cakephp 不起作用
问题描述
我收到此错误:
在此服务器上找不到请求的地址“/panel/admin/services/add_service”
当我提交表单并且我在选择框的控制台中获得正确的值时。
jQuery代码
$('.edit_sub_service_data2').css('display','none');
$('#service_provider_id').change(function(){
var cat_val=$(this).val();
var hiturl= "<?php echo $this->webroot.'admin/test/get_provider?cat_id='; ?>"+cat_val;
jQuery.ajax({
url:hiturl, // Send the data with your url.
type: "GET",
data: {'cat_val': cat_val},
dataType: "json",
success: function(data){
$('#service_service_data_id').html("");
$('#service_service_data_id').html(data[0]);
}
});
});
PHP代码
foreach ($category_data as $key => $value){
$combo[] ="<option value='".$key."'>".$value."</option>";
}
echo json_encode(array($combo));
exit();
表格提交代码
<?php echo $this->Form->input('service_data',array('class'=>'form-control','type'=>'select','id'=>'service_service_data_id')); ?>
此代码显示动态数据,但是当我提交表单时,我的表单没有提交,只是因为 CakePhp 中的这个下拉菜单
解决方案
推荐阅读
- react-native - React-native-fs 报告成功,但似乎失败,因为没有写入文件
- excel - 根据另一个单元格的开头替换特定的单元格值
- java - axios、Spring boot 和 base64 的问题
- python - 如何使用阿里巴巴ODPS python SDK中的Schema.from_lists方法创建模式?
- javascript - 如何更新 Dropzone VueJs 组件上的 prop 选项值?
- c# - Azure 活动目录 C#
- c - C - 通过命令行将输入和输出文本文件传递给我的程序
- google-app-engine - 来自 JSON 的 gcloud auth activate-service-account 设置当前项目
- python - 如何在给定的python文件路径中返回错误行?
- angular - 如何避免在 Angular 中暴露内部组件