Nu apare mesajul daca sa adaugat continutul

Discutii si intrebari legate de scripturi si functii JavaScript, jQuery si Ajax, cod JavaScript in general.
cadou
Mesaje:328

Nu apare mesajul daca sa adaugat continutul

Nu stiu care e problema, am refacut codu de 10 ori, acelasi rezultat, unde am gresit ?

am asa:

in fisierul fisier.js

Cod: Selectaţi tot

$(document).ready(function(){
	$(function(){
$('input#addbanc').click(function(){
	var categorie = $('#categorie').val();
	var banc = $('#banc').val();
	
	var categorie = document.getElementById('categorie').value;
	var banc = document.getElementById('banc').value;
	
	$('.statusadaugareloading').show();
	$('.statusadaugaredelogat').hide();
	$('.statusadaugareerror').hide();
	$('.statusadaugareeror').hide();
	$('.statusadaugareerorr').hide();
	$('.statusadaugareerorrr').hide();	
	$('.statusadaugaresucces').hide();
	
if(categorie.length < 3)
{
	$('.statusadaugareloading').hide();
	$('.statusadaugaredelogat').hide();
	$('.statusadaugareerror').show();
	$('.statusadaugareeror').hide();
	$('.statusadaugareerorr').hide();
	$('.statusadaugareerorrr').hide();	
	$('.statusadaugaresucces').hide();
}

else if(banc.length < 10)
{
	$('.statusadaugareloading').hide();
	$('.statusadaugaredelogat').hide();
	$('.statusadaugareerror').hide();
	$('.statusadaugareeror').show();
	$('.statusadaugareerorr').hide();
	$('.statusadaugareerorrr').hide();
	$('.statusadaugaresucces').hide();
}
	
else   {      $.ajax({
        	url:'/addbanc.php?bancuri&categorie='+categorie+'&banc='+banc,
        	type: "POST",
			Async: false,
			cache: false,
        	success:function(data_response){
				if(data_response == 'exista') {	
	$('#categorie').val('');
	$('#banc').val('');				
	$('.statusadaugareloading').hide();
	$('.statusadaugaredelogat').hide();
	$('.statusadaugareerror').hide();
	$('.statusadaugareeror').hide();
	$('.statusadaugareerorr').show();
	$('.statusadaugareerorrr').hide();
	$('.statusadaugaresucces').hide();
        		} 
				else if(data_response == 'datele nu sau adaugat') {		
	$('#categorie').val('');
	$('#banc').val('');				
	$('.statusadaugareloading').hide();
	$('.statusadaugaredelogat').hide();
	$('.statusadaugareerror').hide();
	$('.statusadaugareeror').hide();
	$('.statusadaugareerorr').hide();
	$('.statusadaugareerorrr').show();
	$('.statusadaugaresucces').hide();
        		}				
				else if(data_response == 'banc adaugat') {	
	$('#categorie').val('');
	$('#banc').val('');
	$('.statusadaugareloading').hide();
	$('.statusadaugaredelogat').hide();
	$('.statusadaugareerror').hide();
	$('.statusadaugareeror').hide();
	$('.statusadaugareerorr').hide();
	$('.statusadaugareerorrr').hide();
	$('.statusadaugaresucces').show();
        		}				
				else if(data_response == 'delogat') {	
	$('#categorie').val('');
	$('#banc').val('');
	$('.statusadaugareloading').hide();
	$('.statusadaugaredelogat').show();
	$('.statusadaugareerror').hide();
	$('.statusadaugareeror').hide();
	$('.statusadaugareerorr').hide();
	$('.statusadaugareerorrr').hide();
	$('.statusadaugaresucces').hide();
        		}
				}
			}); 
			};
		});
	});
});

html

Cod: Selectaţi tot

formularul +
	<div class="statusadaugareloading" style="display:none;">
		<center><img class="loading"  src=/imagini/stare-loading.gif>
			<font color=orange>Te rugam asteapta!</font>
		</center>
	</div>		
	<div class="statusadaugareerror" style="display:none;">
		<center><img class="error"  src=/imagini/stare-error.png>
			<font color=red>Alege categoria bancului!</font>
		</center>
	</div>	
	<div class="statusadaugareeror" style="display:none;">
		<center><img class="error"  src=/imagini/stare-error.png>
			<font color=red>Scrie un banc, bancul trebuie sa contina minim 10 caractere!</font>
		</center>
	</div>		
	<div class="statusadaugareerorr" style="display:none;">
		<center><img class="error"  src=/imagini/stare-error.png>
			<font color=red>Acest banc exista deja pe site! Adauga altul!</font>
		</center>
	</div>		
	<div class="statusadaugareerorrr" style="display:none;">
		<center><img class="error"  src=/imagini/stare-error.png>
			<font color=red>S-a intamplat ceva de nu sa putut adauga bancul, da un F5 la pagina sau revin-o in cateva minute!</font>
		</center>
	</div>	
	<div class="statusadaugaresucces" style="display:none;">
		<center><img class="succes"  src=/imagini/stare-succes.png>
			<font color=green>Bancul a fost adaugat si este deja vizibil.
				Intre timp poti sa mai adaugi si alte bancuri!</font>
		</center>
	</div>	
	<div class="statusadaugaredelogat" style="display:none;">
		<center><img class="error"  src=/imagini/stare-error.png>
			<font color=red>Pentru a putea adauga un banc trebuie sa fi inregistrat
				si logat pe site!</font>
		</center>
	</div>
problema e ca atunci cand dau sa adaug erorile imi apar gen: alege categoria sau scrie un banc ... etc. dar cand sa adaugat nu imi apare mesajul din div-ul statusadaugaresucces .
din fisierul addbanc raspunsurile sunt :
banc adaugat
delogat
Datele nu s-au adaugat.

Unde am gresit? l-am refacut de 10 ori, acelasi rezultat

MarPlo Mesaje:4343
Salut
Nu stiu care e problema, din cod lipseste formularul cu elementele "addbanc", "categorie", "banc".
In plus, valorile de la atributele: src, color; nu sunt intre ghilimele.
- Ca sugestie, te ajuta sa folosesti addon-un Firebug in Mozilla; iti arata erorile din codul javascript

cadou Mesaje:328
Codul e functional, imi adauga sau apar erorile cand trebuie, singura problema este ca nu imi apare mesajul de adaugare succes.
folosesc firebug dar nu imi arata nici o eroare!

- Edit:
Am descoperit problema,m este aici :

Cod: Selectaţi tot

if(data_response == 'exista') 
si la restu conditiilor e dublu egal
corect e asa
if(data_response = 'exista')