jQuery的AJAX和PHP的模具() [英] Jquery ajax and php die()

查看:146
本文介绍了jQuery的AJAX和PHP的模具()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个IE浏览器的问题。我使用jQuery AJAX方法来调用PHP脚本。在PHP脚本只是调用死亡()。在Firefox中,会显示错误消息,但在IE中显示成功消息,没有任何数据。我想preFER误差函数被调用。

有什么办法解决这一问题?我猜我的javascript code需求的变化不知。

谢谢!

 < PHP
    死()
?>

$阿贾克斯({
    网址:PHPS / php.php ID =+ the_id,
    数据类型:JSON,
    错误:函数(){
        警报('错误');
    },
    成功:功能(数据){
        警报(成功);
    }
});
 

解决方案

我想Firefox和其他浏览器不考虑空调用一个错误,但在你的PHP脚本,如果你想使所有的IE不,试试这个他们犯错:

 标题(HTTP / 1.0 400错误的请求);
 

从维基百科:

  

400错误的请求       该请求有语法错误或无法实现。

I have an IE problem. I am using the jquery ajax method to call a php script. The php script just calls die(). In firefox, the error message is displayed, but in IE the success message is displayed without any data. I would prefer the error function to be called.

Is there any way to fix this? I'm guessing my javascript code needs change somehow.

Thanks!

<?php
    die()
?>

$.ajax({
    url: "phps/php.php?id="+the_id,
    dataType: "json",
    error: function(){
        alert('error');
    },
    success: function(data){
        alert("SUCCESS");
    }
});

解决方案

I guess Firefox and the other browsers do consider an empty call an error, but IE does not, try this in your PHP script if you want to cause all of them to err:

header("HTTP/1.0 400 Bad Request");

From wikipedia:

400 Bad Request The request contains bad syntax or cannot be fulfilled

这篇关于jQuery的AJAX和PHP的模具()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆