<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[jQuery] Problema funzione]]></title><description><![CDATA[<p dir="auto">Ciao a tutti, ho la seguente funzione jQuery:</p>
<pre><code>$('#nearStore').bind('click',function(){
	if(jQuery('#nearStore').attr('disabled') === 'disabled')
		return;
	jQuery('#searchResult').empty();
	jQuery('.DHead').remove();
	$('#msgBox').text("");
	$('#msgBox').removeClass('success').removeClass('error');
	jQuery('#searchResult').append("&lt;ul class='SearchR'&gt;&lt;/ul&gt;");
	var geocoder = new google.maps.Geocoder();
    var name = jQuery('#tbName').val();
	var radian = jQuery('#selRadius').val();
	var CatId = 0;
	if(jQuery('#selCategory').length &gt; 0){
		CatId = jQuery('#selCategory').val();
		jQuery('#hdfOCatId').val(CatId);
	}else{
		CatId = 0;
		jQuery('#hdfOCatId').val(0);
	}		
	if(jQuery.trim(name).length &lt;= 0){
		jQuery('#tbName').addClass('error_cls');
		jQuery('#tbName').focus();
		$('#msgBox').text("Inserisci il nome per la ricerca.");
		$('#msgBox').removeClass('success').addClass('error').fadeOut(300).fadeIn(300);
	}else if(jQuery.trim(radian).length &lt;= 0){
		jQuery('#selRadius').addClass('error_cls');
		jQuery('#selRadius').focus();
		$('#msgBox').text("Seleziona il raggio.");
		$('#msgBox').removeClass('success').addClass('error').fadeOut(300).fadeIn(300);
	}else{
		jQuery('#tbName,#selRadius').removeClass('error_cls');
		//CERCO NEGOZIO IN BASE AL NOME O ALLA PAROLA CHIAVE
		jQuery.ajax({
			type: "POST",
			url: "ajax/ajx_manageStore.php",
			data: "Method=SearchSelect&amp;tbName=" + name,
			success: function(msg){
				if(msg == ""){
					jQuery('#tbName').addClass('error_cls');
					jQuery('#tbName').focus();
					$('#msgBox').text("Nessun negozio trovato con i criteri impostati");
					$('#msgBox').removeClass('success').addClass('error').fadeOut(300).fadeIn(300);
				}else{
					//STORE TROVATO, CERCO INDIRIZZO E METTO NELLA VARIABILE address			
//PUNTO 1
					$('#tbPlace').attr('value',msg);
				}
			}
		});
//PUNTO 2
		address=$('#tbPlace').attr('value');
		geocoder.geocode( { 'address': address}, function(results, status) {
		if (status == google.maps.GeocoderStatus.OK) {
			var latitude = results[0].geometry.location.lat();
			var longitude = results[0].geometry.location.lng();            
	
			if(radian == null || radian == ''){
				radian = 2;
			}
			var RadType = (jQuery('input:radio[name=radius]:checked').val()) ? jQuery('input:radio[name=radius]:checked').val() : "Kms";
			RadType = (RadType == 'KM') ? 'Kms' : 'Miles';
			radian = (RadType === 'Miles') ? Math.round(radian*1.609) : radian;
			jQuery('#nearStore').attr('disabled', 'disabled');
				SearchStore(latitude, longitude, radian, RadType, CatId);                                
			}else if(status == google.maps.GeocoderStatus.ZERO_RESULTS){  
				jQuery('.SearchR li').remove();  
				jQuery('.SearchR').empty();
			}
		});
	}
});
</code></pre>
<p dir="auto">Perché esegue prima il "Punto 2" del "Punto 1"?<br />
Infatti mi crea problemi perchè la variabile address è ancora vuota..<br />
Se ri-eseguo la funzione una seconda volta invece funziona tranquillamente perchè il campo <a href="/hashtags/tbplace">#tbPlace</a> lo ritrova già popolato dall'esecuzione precedente...</p>
]]></description><link>https://dev.connect.gt/topic/195051/jquery-problema-funzione</link><generator>RSS for Node</generator><lastBuildDate>Wed, 25 Nov 2026 09:30:45 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/195051.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 20 Oct 2013 09:06:12 GMT</pubDate><ttl>60</ttl></channel></rss>