Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 142
  • Last Modified:

response in ajax and php

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
joyacv2
Asked:
joyacv2
  • 7
  • 7
  • 3
  • +1
1 Solution
 
GaryCommented:
Well that rather depends on what your page is returning to the ajax call
0
 
leakim971PluritechnicianCommented:
replace :
response
by :
response * 1
0
 
joyacv2Author Commented:
where i need to change response to response*1?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
leakim971PluritechnicianCommented:
line 11
0
 
joyacv2Author Commented:
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
 
leakim971PluritechnicianCommented:
so << * 1 >> does'nt make sense until you compare with a number
0
 
joyacv2Author Commented:
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
 
leakim971PluritechnicianCommented:
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
 
joyacv2Author Commented:
my text is the same that i summit the response variable don't compare text only numbers, with the 999999999999 works well
0
 
joyacv2Author Commented:
with this alert, i got the value but don't compare in the if statement
0
 
leakim971PluritechnicianCommented:
screen copy ?
a link to see that?
0
 
joyacv2Author Commented:
sorry, i don't have anyone
0
 
Ray PaseurCommented:
0
 
leakim971PluritechnicianCommented:
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
 
joyacv2Author Commented:
0
 
GaryCommented:
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
 
leakim971PluritechnicianCommented:
not "<br>test"
but : "\ntest"

first one is html
0
 
GaryCommented:
I was more trying to indicate there was another line, thought <br> would make it obvious ;o)
0

Featured Post

Industry Leaders: 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!

  • 7
  • 7
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now