Passing a function to change page in jquery mobile

173 Views Asked by At

Am trying to pass a function on change page in jquerymobile but i get an error which points to $.ajax

$( ":mobile-pagecontainer" ).pagecontainer(
    "change",
    "#schoolperformance",
    { reload : true, showLoadMsg : false,

      $.ajax({
          type: 'POST',
          url: "custom/php/showinfo.php",

          success: function(data){
              $("#new").html(data)
          },

          error: function(){  //on error

              console.log('failed to successifuly destroy');
          }

      });

    });
1

There are 1 best solutions below

0
jcubic On

You can't pass ajax without a function and pagecontainer don't accept a function in change method, try to use change event instead:

$(":mobile-pagecontainer").pagecontainer({
  change: function(event, ui) {
      $.ajax({
          type: 'POST',
          url: "custom/php/showinfo.php",

          success: function(data){
              $("#new").html(data)
          },

          error: function(){  //on error

              console.log('failed to successifuly destroy');
          }

      });
  }
});
$(":mobile-pagecontainer").pagecontainer("change", "#schoolperformance", {
   reload: true,
   showLoadMsg: false
});