A gallery can count a hundred photos and the site may have several user gallery alone is me. My Ajax code
Code:
<script type="text/javascript">
var xmlhttp = false;
if (window.ActiveXObject) {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
xmlhttp.overrideMimeType('text/xml');
}
function exReq(){
//var state = document.forms[0].elements[0].value;
//var url = 'ajax.php?state='// + state;
xmlhttp.open('GET','ajax.php',true);
xmlhttp.onreadystatechange = writeResponse;
xmlhttp.send(null);
}
function writeResponse() {
str1="";
str2="";
str3="";
var state=xmlhttp.status;
//clearTimeout(newtimer);
switch (xmlhttp.readyState){
case(2):var call1 = setTimeout(str1=rqSent(state),5000);
//clearTimeout(call1);
case(3):var call2 = setTimeout(str2=waitRq(state),5000);
//clearTimeout(call2);
case(4):var call3 = setTimeout(str3=response(state),5000);
alert(typeof(str3));
break;
}
var myid = document.getElementById('display');
myid.innerHTML=str3;
//clearTimeout(call3);}
}
function rqSent(state){
var str1 ="request sent status is :"+state;
return str1;
}
function waitRq(state){
var str2 ="Response being received...the status is :"+state;
return str2
}
function response(state){
var str3 ="Response is :"+xmlhttp.responseText+" the status is :"+state;
return str3
}
function init(){
exReq();
}
newtimer = setTimeout("init()",6000);
</script>
<body>
<div id="display"></div>
</body>
My php code in php4
I pass in php5 but now they're acting to a query quickly
PHP Code:
<?php
require ("Connect.php");
function recupDatabase(){
$connection = mysql_pconnect (SERVER,NAME,PASSWORD);
if (! $connection)
{
echo"Sorry, connection to " . SERVER." impossible\n";
exit;
}
if (! mysql_select_db (BASE,$connection))
{
echo "Sorry, access to basic " . BASE . " impossible\n";
}
$sql = "SELECT * FROM `gallery`";
$req = mysql_query($sql) or die('<u>SQL Problem</u> : '.$sql.'<br>'.mysql_error
());
$num_rows = mysql_num_rows($req);
while($result = mysql_fetch_array($req)) {
$nametrack[] = $result['track'];
$headline[] = $result['headline'];
$title[] = $result['title'];
$image[] = $result['image'];
$name[] = $result['name'];
$miniature[] = $result['miniature'];
$numphotoclick[] = $result['numphotoclick'];
}
$database = array($nametrack,$headline,$title,$image,$name,$miniature,$numphotoclick);
return $database;
}
recupDatabase();
?>
An echo database sends a string that is "array" and who is not an array
transmits a return "nothing"
My goal is simply to import my database and its data fields so their values
in a JavaScript table. Then I manipulate the data via Ajax client side on the table. The goal is to limit the requests. I intend to use nicknames in JavaScript and class methods and make an application independent as possible from the server. Ajax becomes a kind of Applet
Bookmarks