Solved

response in ajax and php

Posted on 2014-09-10
18
135 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
  • 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
 
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
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.

 
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 108

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

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

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
This article discusses how to create an extensible mechanism for linked drop downs.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

867 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