...

View Full Version : Help ,Ajax,and php (Updating data)



aymanstar
12-10-2006, 06:35 AM
Hello, I user This Code in My site I want help

when i try to enter data from my site admin cp its not add to the result in my ajax page if i open it befor enter data that i want to show from my admin but if try to delete temp files from explorer the new data apper why ?
i am use 2 Element in my code i want to make new function when i call this function it request the 1st Element (Callmain) and inside this open the 2nd Element (ajaxTest)

Thx For Your Help


function createRequestObject() {
var req;
if(window.XMLHttpRequest){
req = new XMLHttpRequest();
} else if(window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
} else {
alert('حصل خطأ في طلب الصفحة...الرجاء المحاولة مرة أخرى وإذا لم تنفع جرب أن تنزل نسخة جديدة من المتصفح');
}
return req;
}

var http = createRequestObject();

function sendRequestGet(letter) {
http.open('get', 'Show.php?letter='+letter, true);
http.onreadystatechange = handleResponse;
http.send(null);
}
function sendRequestalbum(SingerID) {
http.open('get', 'Showsong.php?SingerID='+SingerID, true);
http.onreadystatechange = handleResponse;
http.send(null);
}
function sendRequestalbumsongs(AlbumID) {
http.open('get', 'Showsong.php?AlbumID='+AlbumID, true);
http.onreadystatechange = handleResponse;
http.send(null);
}

function handleResponse() {
var ajaxTest = document.getElementById("ajaxTest");
ajaxTest.innerHTML = '<div id="genLoading"><img src="images/progressbar.gif" alt="Loading Content" border="0" /><div>Loading Content</div></div>';
if(http.readyState == 4 && http.status == 200){
var response = http.responseText;
if(response) {
ajaxTest.innerHTML = response;
}
}
}
function sendRequestsong() {
http.open('get', 'Showsong.php', true);
http.onreadystatechange = handleResponsex;
http.send(null);
}
function handleResponsex() {
var callmain = document.getElementById("callmain");
callmain.innerHTML = '<div id="genLoading"><img src="images/progressbar.gif" alt="Loading Content" border="0" /><div>Loading Content</div></div>';
if(http.readyState == 4 && http.status == 200){
var response = http.responseText;
if(response) {
callmain.innerHTML = response;
}
}
}
function sendRequestsmain(letter) {
http.open('get', 'Showsong.php', true);
http.onreadystatechange = handleResponsex;
http.send(null);



}

david_kw
12-10-2006, 07:01 AM
I'm not sure I understand your problems but in regard to your first bullet point I wanted to let you know a problem that I have had.

Internet Explorer seems to set XML retrieved by AJAX in the cache and will wait until the expiration date is hit before it is refreshed (even if you refresh the page). The only way I know to fix this problem is to have your server set the expiration date as "now" or the current date/time or whatever to let IE know the cached version needs to be refreshed.

So the HTTP header can have things like:

Cache-Control: no-cache
Expires: Sat, 9 Dec 2006 00:00:00 GMT

How you set those will depend on your backend solution.

Hopefully that helps.

david_kw

aymanstar
12-10-2006, 07:15 AM
thx david_kw
about am use 2 Element in my code i want to make new function when i call this function it request the 1st Element (Callmain) and inside this open the 2nd Element (ajaxTest) ?
what i will do ?

david_kw
12-10-2006, 07:26 AM
Is this with an XML return? Can you show me a sample XML file?

aymanstar
12-10-2006, 07:49 AM
NO http request

i put inside my html for example

in main requested page


<div id="" dir="ltr"></div>
and inside it put in center down for example

<div id="ajaxTest" dir="ltr"></div>

i can call each one lonly (Alone)
Example
from home page click AJAX lnk
register form apper (callmain)
and if click ajax2
register apper and page x aper in center mid (ajaxTest)
but i need to call ('callmain' and 'ajaxTest' inside 'callmain'
my code

function createRequestObject() {
var req;
if(window.XMLHttpRequest){
req = new XMLHttpRequest();
} else if(window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
} else {
alert('حصل خطأ في طلب الصفحة...الرجاء المحاولة مرة أخرى وإذا لم تنفع جرب أن تنزل نسخة جديدة من المتصفح');
}
return req;
}

var http = createRequestObject();

function sendRequestGet(letter) {
http.open('get', 'Show.php?letter='+letter, true);
http.onreadystatechange = handleResponse;
http.send(null);
}
function sendRequestalbum(SingerID) {
http.open('get', 'Showsong.php?SingerID='+SingerID, true);
http.onreadystatechange = handleResponse;
http.send(null);
}
function sendRequestalbumsongs(AlbumID) {
http.open('get', 'Showsong.php?AlbumID='+AlbumID, true);
http.onreadystatechange = handleResponse;
http.send(null);
}

function handleResponse() {
var ajaxTest = document.getElementById("ajaxTest");
ajaxTest.innerHTML = '<div id="genLoading"><img src="images/progressbar.gif" alt="Loading Content" border="0" /><div>Loading Content</div></div>';
if(http.readyState == 4 && http.status == 200){
var response = http.responseText;
if(response) {
ajaxTest.innerHTML = response;
}
}
}
function sendRequestsong() {
http.open('get', 'Showsong.php', true);
http.onreadystatechange = handleResponsex;
http.send(null);
}
function handleResponsex() {
var callmain = document.getElementById("callmain");
callmain.innerHTML = '<div id="genLoading"><img src="images/progressbar.gif" alt="Loading Content" border="0" /><div>Loading Content</div></div>';
if(http.readyState == 4 && http.status == 200){
var response = http.responseText;
if(response) {
callmain.innerHTML = response;
}
}
}
function sendRequestsmain(letter) {
http.open('get', 'Showsong.php', true);
http.onreadystatechange = handleResponsex;
http.send(null);



}

david_kw
12-10-2006, 08:12 AM
I'm sorry but I don't know the answer. Hopefully someone else can help with your issue.

aymanstar
12-10-2006, 08:16 AM
thx david_kw
wait onther anser

aymanstar
12-10-2006, 11:45 AM
whats up ?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum