Jquerymobile mySQL [关闭]

I am doing a website currently for my final year project using joomla and to get a better grade, I am asked to use Jquerymobile for make it easily accessible. However, I have no idea how to retrieve data from my database using mySQL and php in conjunction with Jquerymobile. Can anyone enlighten me?

You have to use Ajax. So use $.ajax, $.postor $.get methods to send a request to your webserver. Then you will request your database with PDO or mysqli as usual, or you will use the joomla API as you want to use joomla.

A basic syntax is for your javascript file, let's say ajaxquery.js. I assume you will send your request by clicking on a button whose id is clickit

(function(){
    var onClickCallback(e){
        //do something with DOM by handling the e object
        $.ajax('yoururl',{data:{var1:"value1",var2:"value2"},type:"get"})
              .success(function(xhr){
                  //display your data here
               ).fail(function(xhr){
                    $("#content").append($('<p class="error">An error occured</p>'));
                });
      }
    $('#clickit').on('click',onClickCallback);
})();

This is basic question. I think you need to learn CURD with PHP and MySQL.

  1. First you need to learn how to connecting PHP and MySQL
  2. You need to learn how to inserting data from PHP to MySQL
  3. You need to learn how to updating data from PHP to MySQL
  4. You need to learn how to updating data from PHP to MySQL

After that, you can use ajax to show your data:

$.post('crud.php', function(data) {
  $('#result').html(data);
});

Good luck.