Solved

response in ajax and php

Posted on 2014-09-10
18
133 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
This article discusses four methods for overlaying images in a container on a web page
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.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now