Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

How do I retrieve data from database and put the data in a JavaScript array variable?

user-image
Question ajoutée par Yasmeen Husam , Web Developer , Al Fahid Systems
Date de publication: 2019/01/30
Mohammed Touil
par Mohammed Touil , Executive Housekeeper , Université international de Rabat

() { $ajax({ type : 'get', url : 'urlofmyfile.py', dataType : 'json', function(availableNumber){ $( "#items" ).autocomplete({ source: availableTags }); } }); });

Ahmed Hussin
par Ahmed Hussin , Co Founder , Ghadi

 

افضل وسيلة عن طريق$(function() { $.ajax({ type : 'get', url : 'urlofmyfile.py', data : 'q='+q, dataType : 'json', success : function(availableTags){ $( "#items" ).autocomplete({ source: availableTags }); } }); });

Utilisateur supprimé
par Utilisateur supprimé

Dear Yasamin,

When you are using AJAX to access DATABASE from HTML or JAVASCRIPT file you are going to have the rsponse as JSON or XML.

$.ajax(

url:"your path"

dataTyp: "JSON/ETC"

success:function(data){

do what ever with data

}

});

Example: If you are using PHP then you have to put function in PHP code to access database and encode the retrieved data in JSON XML or any

function retrieveData(){

/* make connection to database */

$data="SELECT * FROM XTABLE";

$result=json_encode($data);

echo $result;

/* Close connection for prformance and security reasons*/

}

 

 

 

More Questions Like This

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?