Pass PHP parameters to JQuery Mobile Panel

1

Good morning everyone,

I'm trying to do a function where a JQM Panel dynamically receives a page in PHP with some parameters. But it does not work, the panel opens in white. Here is the code I'm using:

     $(".botao").on("mouseup", function (e) {
        var url = $.ajax({
                      method: "GET",
                      url: "menu.php",
                      data: { qtd: "1", linhas: "19" }
                    });     
        opendialog(url);
    });

    function opendialog(page) {
        $("#menu").html(page);
        $("#menu").trigger('updatelayout');
        $("#menu").trigger('create');
        $("#menu").panel("open");
    } 

I have also used .GET instead of .AJAX in the code, also without success.

Thank you in advance for the help.

    
asked by anonymous 31.12.2015 / 12:52

1 answer

2

Try to do this, so you have in success how to assign the ajax callback. Check with the command console.log (return) which will return from this url that you are accessing and performs the assignment to the #id menu elements as desired. After the return of success it will call the trigger and panel does not complete. If an error occurs in the ajax call you can deal with the error.

 $(".botao").on("mouseup", function (e) { 
    $.ajax({
        url: "menu.php",
        method: "GET",
        data: { qtd: "1", linhas: "19" },
        error: function(XMLHttpRequest, textStatus, errorThrown){
           console.log("Trate o Error neste ponto!");
        },
        success: function(retorno) {
            console.log("se tiver duvida do que está retornando: " + retorno);
            $("#menu").html(retorno);                   
        },      
        complete: function(){
            $("#menu").trigger('updatelayout');
            $("#menu").trigger('create');
            $("#menu").panel("open");
        }
    });      
});
    
31.12.2015 / 22:21