AKB Forums

Go Back   AKB Forums > Technical sections > Languages, Compilers and Interpreters > Web Development
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Web Development Java/PHP/Perl/ASP and more

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old Mar 24, 2008, 13:34   #1
Web developer
 
Aram Ghazanchyan's Avatar
 
Join Date: Sep 2002
Location: Yerevan
Posts: 884
Rep Power: 6
Reputation: 14
Send a message via ICQ to Aram Ghazanchyan Send a message via MSN to Aram Ghazanchyan
JavaScript problem with variables-functions in AJAX ( jQuery )

I need to check same login verification submitted from form with help of AJAX/jQuery
Here is the sources ( jQuery file is not included )
main.html
Code:
<script type="text/javascript" language="javascript" src="jquery.js"></script>
<script language="JavaScript" type="text/javascript">
function verif() 
{
	var myErr = '';	
	var f = document.f1reg;
	
	myErr+=" * Fill in all required fields.\n";
	
	$.ajax({
	   type: "POST",
	   url: "checkusername.php",
	   data: "username="+ f.username.value,
	   success: function(msg){
			if (msg == "1"){
				myErr+=' * User with such login already exists.\n';
				//alert(myErr); Label 1
			}
	   }
	 });
	//alert(myErr); Label 2

	if (myErr!='') {
		alert('The following information is incorrect:\t\t\t\t\t\n\n'+myErr); // Label 3
	} 
	return (myErr=='');
}
</script>


<form action="action.php" method="post" name="f1reg" id="f1reg" onsubmit="return verif();">
  
  Login: <input type="text" id="username" name="username" value="" tabindex="1" />
    <input type="submit" name="submit" value="Submit" />
  </div>
</form>
checkusername.php just prints "1"

The problem is the following:
On Label 1, myErr adds an error message to the list
On Label 2, myErr looses the latest message and just shows " * Fill in all required fields.\n";
On Label 3, the same situation as in Label 2
But if I remove Label 2 comment, and alert any message in that part of code, the script starts to working well.
What is the problem?
Aram Ghazanchyan is offline   Reply With Quote Quote selected
Old Mar 24, 2008, 14:37   #2
йес эм эли...
 
Mesrop's Avatar
 
Join Date: Feb 2005
Location: near the computer
Posts: 3,118
Rep Power: 4
Reputation: 48
Send a message via ICQ to Mesrop Send a message via AIM to Mesrop Send a message via MSN to Mesrop Send a message via Yahoo to Mesrop Send a message via Skype™ to Mesrop
inchqan haskaca, problem@ sranic e.
browser@ ajax zapros e uxarkum, bayc chi spasum vor checkusername.php -ic return ani, and minchev ed request@ sksum e gnal, inqe arag ancnum e hajord gorcoxutyane... sax JSn arag ashxatum e, u PHPic chi hascnum stanal variable ev kpcnel myErr -in.
erp label2 -um alert es anum, script@ cuyc e talis et alerti window-@ and kangnum e. ed kangnac vaxt karox a ga PHP-ic qo variablen and kpni myErr -in, u label 3 um arden normal php'ic return exac string unenas.
script@ arden petq e sharunakel function(msg) -i mej, vor return exac lini php'n...
husov em chisht and haskanali er...

Last edited by Mesrop : Mar 24, 2008 at 14:47. Reason: avelacum
Mesrop is offline   Reply With Quote Quote selected
Old Mar 25, 2008, 04:36   #3
Web developer
 
Aram Ghazanchyan's Avatar
 
Join Date: Sep 2002
Location: Yerevan
Posts: 884
Rep Power: 6
Reputation: 14
Send a message via ICQ to Aram Ghazanchyan Send a message via MSN to Aram Ghazanchyan
Haskanalin - haskanalia, bayc de es @tenc liq@ ktorner unem, voric petq e sborka arvi u resultiruyushiy error ta. Aysinqn es chem karoghana menak 1 tvyal-i stugman jamanak verjnakan result@ cuic tam.
Erevi xndir@ aveli global senc tam, vonc karelia Ajax-ov stugel inch vor DB-ic tvyal u dra result@ poxancel inch vor mi JS-i popoxakanin?
Aram Ghazanchyan is offline   Reply With Quote Quote selected
Old Mar 25, 2008, 09:04   #4
йес эм эли...
 
Mesrop's Avatar
 
Join Date: Feb 2005
Location: near the computer
Posts: 3,118
Rep Power: 4
Reputation: 48
Send a message via ICQ to Mesrop Send a message via AIM to Mesrop Send a message via MSN to Mesrop Send a message via Yahoo to Mesrop Send a message via Skype™ to Mesrop
de script@ parberabar petq e pause lini, and server request ani...
uxaki amen requestic heto coden piti sharunakes success: function(msg){} -i mejic...orinak
success: function(msg){check2();} ...
isk vapshe ed depqum imho aveli chisht klini vor 1 zaprosov sax stuges. aysinqn 1 zaprosov uxarkes fieldneri valuenere PHPin, and 1 array'ov return anes from PHP bolor errornere irar het JS variablei mej.
Mesrop is offline   Reply With Quote Quote selected
Old Mar 25, 2008, 09:34   #5
Web developer
 
Aram Ghazanchyan's Avatar
 
Join Date: Sep 2002
Location: Yerevan
Posts: 884
Rep Power: 6
Reputation: 14
Send a message via ICQ to Aram Ghazanchyan Send a message via MSN to Aram Ghazanchyan
Mersi Mesrop.
Kporcenq takic durs ganq.
Aram Ghazanchyan is offline   Reply With Quote Quote selected
Old Mar 25, 2008, 09:37   #6
dardanian
 
aeneas's Avatar
 
Join Date: Nov 2005
Location: new troy
Posts: 173
Rep Power: 3
Reputation: 10
qo request-@ serverin XMLHttpRequest (IE -i hamar el ActiveXObject(....)) object-i mijocov petq a anes. Mesrop -@ &isht a asum, qo js-@ petq a spasi request-i patasxanin server-ic. onreadystatechange event handler-@ ogtagortsi u stugi readyState -i arjeq@ (yete &isht em hishum, request-d complete a yerb vor readyState=4).

readyState-i myus arjeqner@ (u @ndhnrapes ajax-db query -in veraberogh mi vagon urish info) internet-um karas gtnel
__________________
o gloriose stelle, o lume pregno
di gran virtù, dal quale io riconosco
tutto, qual che si sia, il mio ingegno
dante, paradiso - canto 22
aeneas is offline   Reply With Quote Quote selected
Old Mar 25, 2008, 11:07   #7
Web developer
 
Aram Ghazanchyan's Avatar
 
Join Date: Sep 2002
Location: Yerevan
Posts: 884
Rep Power: 6
Reputation: 14
Send a message via ICQ to Aram Ghazanchyan Send a message via MSN to Aram Ghazanchyan
Quote:
Originally Posted by aeneas View Post
qo request-@ serverin XMLHttpRequest (IE -i hamar el ActiveXObject(....)) object-i mijocov petq a anes. Mesrop -@ &isht a asum, qo js-@ petq a spasi request-i patasxanin server-ic. onreadystatechange event handler-@ ogtagortsi u stugi readyState -i arjeq@ (yete &isht em hishum, request-d complete a yerb vor readyState=4).

readyState-i myus arjeqner@ (u @ndhnrapes ajax-db query -in veraberogh mi vagon urish info) internet-um karas gtnel
Es et tegh grel ei jQuery-em ogtagorcum. Ete 1 vagoni masin eq xosum, apa imaceq vor jQuery-n mi hat mec sostava
Aram Ghazanchyan is offline   Reply With Quote Quote selected
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
NHibernate: Problem with Configuration Intel Languages, Compilers and Interpreters 0 Mar 4, 2007 07:49
JavaScript - Frames problem Aram Ghazanchyan Web Development 9 Jun 2, 2003 05:43
JavaScript Encoding Problem Viktor Abovian Web Development 2 Nov 1, 2002 13:30
static variables in class member functions hov Languages, Compilers and Interpreters 6 Sep 23, 2002 19:18
static variables in class member functions hov Languages, Compilers and Interpreters 0 Sep 21, 2002 09:33


All times are GMT. The time now is 08:19.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link