我怎么做一个Ajax请求& &;响应firefox操作系统

How can I make a Ajax request & response with firefox OS?

本文关键字:请求 Ajax 响应 操作系统 firefox 一个      更新时间:2023-09-26

我有一个php函数,从数据库返回Json数据。我想从函数中获取所有json并显示到我的Firefox应用程序中。我尝试了Jquery Ajax。但是这行不通。

任何其他库或Ajax编码?

var a=1;
$.ajax({
     url:"http://localhost/shop/home/home/demo",
     type:"POST",
     data:{b:a},
     success: function(msg){
         alert(msg);
     }
});

不支持firefox应用程序,帮帮我。

必须使用mozSystem属性。下面是一个使用原生XMLHttpRequest的示例。

var xhr = new XMLHttpRequest({
    mozSystem: true
});
xhr.open("POST", "http://localhost/shop/home/home/demo");
xhr.onload = function() {
    if (xhr.status == 200) {
        console.log(xhr.responseText);
    }
};
xhr.send("b=" + a); //serialized data

希望有帮助!