כתבתי לך איזה סקריפט, לא בדקתי אותו אבל אני מקווה שהוא פועל, זה משהו שמעולם לא ניסיתי.
כל מה שאתה צריך לעשות זה לדאוג שהסקריפט שלך יציא פלט כמו זה
ותדאג ששמות הDIV'S שלך יהיו divName_# כאשר # הוא מספר.
* divName_1 יקבל את הערך הראשון במערך וכך הלאה.
function getHTTPObject() { try { req = new XMLHttpRequest(); } catch (err1) { try { req = new ActiveXObject("Msxml12.XMLHTTP"); } catch (err2) { try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (err3) { req = false; } } } return req; } var http = getHTTPObject(); // We create the HTTP Object function handleHttpResponse() { if (http.readyState == 4) { var results = http.responseText; var myDivsValue=new Array(results); var divNum = 1; for (x in myDivsValue) { document.getElementById('divName_'+divNum).innerHTML = myDivsValue[x; divNum++; } } } function enterValuesToDivs() { http.open("GET", 'index.php'), true); http.onreadystatechange = handleHttpResponse; http.send(null); }
|
*תשנה את index.php לקובץ שאתה טוען ממנו.
בהצלחה