Solved

ajax jquery problem

Posted on 2014-12-30
3
64 Views
Last Modified: 2014-12-30
Hi,

I have the following code:
$.ajax({
    url : "pararlectura.php",
    type: "POST",
    success: function(data, textStatus, jqXHR)
    {
		var prueba = data
		alert(prueba)
		
        if (prueba == "YA"){
			
			alert ("test");
			clearInterval(myVar);
		}

Open in new window


My problem is that my alert(prueba) return YA, but alert("test") loop never executes, what is happening?
0
Comment
Question by:joyacv2
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40523458
replace : if (prueba == "YA"){
by : if ($.trim(prueba) == "YA"){
or by : if (prueba.replace(/^[^a-z]|[^a-z]$/gi,"") == "YA"){
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40523468
excellent! i will close this and open another question about something in this code! Thanks!
0
 
LVL 1

Author Closing Comment

by:joyacv2
ID: 40523469
works perfect!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Julian Matz As of jQuery (http://jquery.com/) 1.4 the .live() method (http://api.jquery.com/live/) supports custom events as well as some standard JavaScript events that it previously didn't support. Among these is the submit event. Unlike …
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now