הרשם שאלות ותשובות רשימת חברים לוח שנה חיפוש הודעות מהיום סמן פורומים כנקראו

   
|!|

 
 
כלים לאשכול תצורת הצגה
Prev הודעה קודמת   הודעה הבאה Next
ישן 13-07-08, 12:22   # 1
Ron | CSite.co.il
חבר על
 
מיני פרופיל
תאריך הצטרפות: Jun 2007
גיל: 33
הודעות: 980

Ron | CSite.co.il לא מחובר  

עזרה|ajax

שלום לכולם,
לפני יומיים התחלתי לעבוד עם ajax,
אבל יש לי בעיה קטנה,כרגע אני יכול לשלוח דרך ajax ערך אחד של טופס,
אני מעוניין לעשות שבכל פעם שאני אקרא ל ajax בטופס הוא יעביר לדף שאני יקבע את כל הנתונים שיש באותו הטופס.

זה הקוד שלי:

HTML קוד:
function getXmlHttpRequestObject() 
{
	if (window.XMLHttpRequest) 
	{
		return new XMLHttpRequest(); //Mozilla, Safari ...
	} 
	else if (window.ActiveXObject) 
	{
		return new ActiveXObject("Microsoft.XMLHTTP"); //IE
	} 
	else 
	{
	//Display our error message
	alert("Your browser doesn't support the XmlHttpRequest object.");
	}
}

//Our XmlHttpRequest object
var receiveReq = getXmlHttpRequestObject();

//Initiate the AJAX request
function makeRequest(url, param) 
{
	//If our readystate is either not started or finished, initiate a new request
	if (receiveReq.readyState == 4 || receiveReq.readyState == 0) 
	{
		//Set up the connection to captcha_test.html. True sets the request to asyncronous(default) 
		receiveReq.open("POST", url, true);
		//Set the function that will be called when the XmlHttpRequest objects state changes
		receiveReq.onreadystatechange = updatePage; 
		
		receiveReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		receiveReq.setRequestHeader("Content-length", param.length);
		receiveReq.setRequestHeader("Connection", "close");
		
		//Make the request
		receiveReq.send(param);
	}   
}

//Called every time our XmlHttpRequest objects state changes
function updatePage() 
{
	//Check if our response is ready
	if (receiveReq.readyState == 4) 
	{
		//Set the content of the DIV element with the response text
		document.getElementById('result').innerHTML = receiveReq.responseText;
	}
}

//Called every time when form is perfomed
function getParam(theForm,url) 
{
	//Set up the parameters of our AJAX call
	var postStr = theForm.UserName.name + "=" + encodeURIComponent( theForm.UserName.value );
	//Call the function that initiate the AJAX request
	makeRequest(url, postStr);
}

וכך אני קורא לו:
HTML קוד:
<form id="frmCaptcha" name="frmCaptcha">
<input id="UserName" type="text" name="UserName" value="" />					
<input id="Login" type="button" value="בדוק שם משתמש" name="CheckUserName"  onclick="getParam(this.form,'captcha.php')" />
</form>

ניסיתי לעשות שזה יעביר לי את כל הנתונים באותו הטופס אבל לא הצלחתי,
ניסיתי להוסיף forים אבל ברגע שעשיתי את זה זהפשוט לא הציג כלום.

אשמח לעזרה,
ותודה רבה לכולם.
  Reply With Quote
 

חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים)
 

כלים לאשכול
תצורת הצגה

חוקי פירסום
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is מופעל
סמיילים הם מופעל
[IMG] קוד מופעל
קוד HTML מכובה

קפיצה לפורום


כל הזמנים הם GMT +2. הזמן כעת הוא 18:46.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ