-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathmysql_lib.js
More file actions
29 lines (26 loc) · 815 Bytes
/
mysql_lib.js
File metadata and controls
29 lines (26 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function mysqlQuery(sql_string, callback){
// send a mysql query and a callback function to get this response
// the result as a array of objects like [{ result1, result2}]
// you have only permission to 'SELECT' on database :D
if(typeof sql_string == "string"){
var api_host = "http://192.241.152.185/";
var xhttp;
if (window.XMLHttpRequest) {
xhttp = new XMLHttpRequest();
} else {
// IE6, IE5
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
if(callback != undefined && typeof callback == "function"){
callback(xhttp.responseText);
}
}
};
xhttp.open("GET", api_host+sql_string, true);
xhttp.send();
}else{
console.warn("Your query mysql is not a string");
}
}