2015-09-25 45 views
1

我有一个PHP函数,它从数据库返回一个Json数据。 我想从函数中获取所有json并将其显​​示到我的Firefox应用程序中。我试过JQuery Ajax。但它不工作。如何使用firefox操作系统创建Ajax请求和响应?

任何其他库或Ajax编码?

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

它不适用于Firefox应用程序。帮我。

+0

您是否收到任何错误? – llanato

回答

3

您必须使用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 

希望它有帮助!

+0

谢谢...简短又甜蜜的回答。 –

+0

我很乐意帮忙! –

+0

请帮帮我! http://stackoverflow.com/questions/32836348/firefox-os-content-security-policy-error-xhr-based-application-in-index-html –