javascriptphpjqueryjsonfirefox-os

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


I'm having a php function which returns a Json data from db. I want get all the json from the function and display that into my Firefox App. I tried Jquery Ajax. But its not working.

Any other library or Ajax coding?

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

It's not working with firefox app. Help me.


Solution

  • You must use the mozSystem property. Here's an example using native 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
    

    Hope it helps!