javascript - How to get MySQL query result returned using $.ajax -


I'm trying to update is a JavaScript, when you hover over an image, a devi Floats near your mouse, this information is stored in an .js file as an array,

for example.

  text [0] = ["image 1", "data1"] text [1] = ["image2", "data2"]  

In the past, if the array change / add / delete the data it will need to upload a new copy .js file, if the data was attached / deleted, then the new image needs a change in .dwt file Which can update each file using the .dwt file as the main template, which can result in 20+ pages They are uploaded

I thought that I can automate this record by using the database and using the database if they are active and use only mysql queries which are active, such a black app The database can be added and disabled, thus eliminating the need for every soft upload of the file.

To do this, I had planned to store the information in the database and create the above array based on the results, by researching how to use the mysql query in JavaScript, Moves to the kind of code

  $ Ajax ("path / to / Your.php") .done (function () {warning ("success");}). File (function () {warning ("error";})  

Now I understand that I need to create a .php file that runs my query and the result of the query in my formatting array will be in a .done part but I do not understand that What should I do to output the query result in the .php file, how .not part is being considered in the context of the output

The bellow code that I use to resize my query results on the page to ensure that I'm getting the result

  $ resultIndex = 0 While ($ line = $ result-> fetch_array (MYSQLI_ASSOC)) {echo '' strval ($ resultIndex). '& Gt; & lt; br & gt;'; echo 'id =' strval ($ Line ['id']). '' Echo 'name =' strval ($ line ['name']). '' 
'; echo' desc = 'strval ($ Line ['desc']). '& Lt; br & gt;' echo 'active =' strow ($ line ['active']). '& Lt; Br> & # 39; & # 39; Echo '----------------------- & lt; Br> & # 39; & # 39; $ Result = + 1; }

I'm thinking 2 things

  1. Am I just typing echo or print_r What do I want from my .php file

  2. How do I .php file .done

    < / Li>

I recommend using the output in Jason. Yes, simply resume the output on success, callback is passed with the data from the server.

  $ Post (url, function (data) {// some stuff with data from server});  

View


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -