Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 14:55

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



string return = undefined außer wenn vorher alert

Discussion on string return = undefined außer wenn vorher alert within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jun 2011
Posts: 225
Received Thanks: 8
string return = undefined außer wenn vorher alert

Ich kenne mich nicht sonderlich gut aus mit JS aber ich habe ein PRoblem mit einer Methode die ein String zurück liefern soll:

Code:
var y;
	$.get("map.php", function(data){
		var x = data;
		x = x.substring(x.search(/Position/), x.length);
		x = x.substring(0, x.search(/<\/p>/));
		
		y = x.substring(0, x.length);})
return y;
Diese Methode liefert "undefined" zurück.

Code:
var y;
	$.get("map.php", function(data){
		var x = data;
		x = x.substring(x.search(/Position/), x.length);
		x = x.substring(0, x.search(/<\/p>/));
		
		y = x.substring(0, x.length);});
alert(y);
return y;
Also ich habe nur ein alert(y); hinzugefügt.
Das Fenster zeigt ebenso "undefined" an, die Methode liefert jetzt aber den gewünschten Wert zurück??
Krabat2 is offline  
Old 11/12/2015, 02:59   #2
 
Mikesch01's Avatar
 
elite*gold: 203
Join Date: Sep 2007
Posts: 732
Received Thanks: 190
Das liegt wohl daran, dass $.get asynchron läuft und bis die Daten angekommen sind, ist der Wert nicht definiert.
Mikesch01 is offline  
Old 11/12/2015, 14:37   #3
 
elite*gold: 0
Join Date: Jun 2011
Posts: 225
Received Thanks: 8
Ah ok, mein Fehler ich werde sicherlich eine funktion finden die erst anfängt sobald die Daten da sind thx
Krabat2 is offline  
Old 11/13/2015, 11:00   #4



 
Serraniel's Avatar
 
elite*gold: 2222
The Black Market: 204/1/0
Join Date: May 2010
Posts: 6,851
Received Thanks: 5,106
mit .ajax kannst du asynch: false setzen.
Serraniel is offline  
Reply


Similar Threads Similar Threads
Search string in File and return value C#
10/26/2014 - .NET Languages - 2 Replies
Hello guys. I want to code following to for the MMORPG Nostale (or rather the String files of it). There is a monster.txt (where the monster strings are) and there is a monster.dat (where the stats from the monsters are, including string name and VNUM (!)) There are examples for the files I told you.
Newbie alert! (the return of the noob)
02/26/2011 - Silkroad Online - 2 Replies
K so from all what people are saying on forums and RL looks like Arabians are not coming, at least not soon so i decided to go for Chinese. Question is, i noticed no one at all plays with bow, but also noticed that primary skill line in bow mastery is full of critical strike chance/damage bonus thingy, and that sounds kinda powerful, so why no one is going bow? is it bad on the long run? Also since botting from 30 to 110 will take enough time for Egypt to have Nukes should i rather go for...
C++ Dll mit AutoIt callen --> Return String bzw. Char
01/22/2011 - C/C++ - 5 Replies
Sers Com, Nicht Funktionierendes Beispiel: AutoIt: $string="h" $Returned=DllCall("Dll-Test.dll"," char:cdecl","string","char&quo t;,$string) MsgBox(0,"DLL-Test",$Returned) C++ Dll: extern "C"



All times are GMT +2. The time now is 14:55.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.