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
Solved

response in ajax and php

Posted on 2014-09-10
18
137 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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 109

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

839 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