Solved

response in ajax and php

Posted on 2014-09-10
18
140 Views
Last Modified: 2014-09-11
function lectura(){
   
        $.ajax({
                url:   'lectura.php',
                type:  'post',
                beforeSend: function () {
                        $("#mensaje").html("Procesando, espere por favor...");
                },
                success:  function (response) {
					
						if (response == 999999999999999999999999999999){
							setTimeout(lectura(), 2000);
							$("#mensaje").html('espere unos segundos......');	
						}else{
    						$("#mensaje").html(response);
						}  
                }
        });

Open in new window


If i change the response == 99....... to a variable type text in the php and here don't work, only works if I compare with a number, why?
0
Comment
Question by:joyacv2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
  • 3
  • +1
18 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40314712
Well that rather depends on what your page is returning to the ajax call
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40314719
replace :
response
by :
response * 1
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40314739
where i need to change response to response*1?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 82

Expert Comment

by:leakim971
ID: 40314745
line 11
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40314766
function lectura(){
   
        $.ajax({
                url:   'lectura.php',
                type:  'post',
                beforeSend: function () {
                        $("#mensaje").html("Procesando, espere por favor...");
                },
                success:  function (response) {
                              
                                    if (response * 1 == "test"){
                                          setTimeout(lectura(), 2000);
                                          $("#mensaje").html('espere unos segundos......');      
                                    }else{
                                        $("#mensaje").html(response);
                                    }  
                }
        });

change 99..... to test and in the php too and stop working
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40314770
so << * 1 >> does'nt make sense until you compare with a number
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40314774
ok, my problem is that compare in the if statement only works with numbers and not with text, and i don't know why?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40314781
where to see your code ?
what do you get in the alert doing this :
 success:  function (response) {
                              alert("<" + response + ">");
                                    if (response * 1 == "test"){

Open in new window

0
 
LVL 1

Author Comment

by:joyacv2
ID: 40314787
my text is the same that i summit the response variable don't compare text only numbers, with the 999999999999 works well
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40314789
with this alert, i got the value but don't compare in the if statement
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40314807
screen copy ?
a link to see that?
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40314816
sorry, i don't have anyone
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 40314840
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40314873
a screen copy, just hit the Print key once you have the alert and paste it in word document or a image editing tools to save it
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40315061
0
 
LVL 58

Expert Comment

by:Gary
ID: 40315158
Looks like you have a carriage return, so testing for test will not work since the response is

<br>
test

Open in new window

0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40315258
not "<br>test"
but : "\ntest"

first one is html
0
 
LVL 58

Expert Comment

by:Gary
ID: 40315285
I was more trying to indicate there was another line, thought <br> would make it obvious ;o)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

705 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