?
Solved

response in ajax and php

Posted on 2014-09-10
18
Medium Priority
?
141 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
Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

 
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 111

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 2000 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

How To Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
Suggested Courses

762 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