2015-09-25 30 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 –