我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

从REST API处理客户端错误

I use ajax() and the result I got is a list of object array. When user pass invalid param, instead of the server side give me an invalid message it gave me fatal error (PHP). I have no control over the PHP, how should I catch if there's invalid respond?

I can't do respond == 'undefined'.

I think you are using $.ajax() of jQuery?

$.ajax({ 
 url: 'myphpfile.php',
 type: 'get',
 datatype: 'json',
 success: function(data) {
  alert('No PHP file error');
 }
// now with error handling
,error {
 alert('PHP file error');
}

});

近期文章

  • oracle序列和并发
  • 用C#代码写一个数据库导入系统,只是将excel表导入到SQL2008数据库中
  • if if条件在htaccess for admin和frontend在open cart中?
  • file_exists在XAMPP上返回false
  • Drupal + Google登录
  • 未设定的对象值
  • Wordpress - 小工具参数
  • 将数组的集合转换为对象
  • 404在POST上但在GET Slim应用程序上没有
  • PHP页面只能看到POST数组值中的71项
  • Laravel 5模型和定制方法的范围
  • 如何将html转换为dynatable或datatable
  • MySql如果where子句失败则插入信号
  • 如何在PHP Microframework Lumen中访问语言文件
  • 多线程数据库插入,具有递增的本地ID
  • 您可以使用RBAC为每个组设置个人权限吗?
  • 基于特定的子目录using.htaccess重写url
  • PHP-在查询中使用别名时的未定义索引
  • 如何在单个视图中将Joomla中的SEF URL更改为非SEF URL?
  • Codeigniter - 使用变量时无法更新数据库

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华