JQuery AJAX returned too much data that I had not requested

Posted by kwokwai on Stack Overflow See other posts from Stack Overflow or by kwokwai
Published on 2010-06-12T15:01:48Z Indexed on 2010/06/12 15:12 UTC
Read the original article Hit count: 223

Filed under:

Hi all,

I am using CakePHP 1.26 and CDN JQuery in this URL: http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js

In a HTML web page, I have these lines of code:

 $.ajax({
      type: "POST",
      url: "http://mywebsite.com/controllers/avail/"+curl,   
      success: function(data) {         
      alert(data);}

});

and in the PHP page, I got another few lines of code:

 function avail($uname){  
              $result1=$this->Site1->User->findByusername($uname);  
               if($result1){
                return 1;
                            }
               else{
                 return 0;
                   }
        }  

As you see, the Avail function will return either zero or one. But there was some redundant data returned from the server,
what I saw in the Alert box was somthing like this (rather than 0 or 1):

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">    
    <html xmlns="http://www.w3.org/1999/xhtml">    
    <head>    
    <title>Missing Method in Controller</title>    
    <meta http-equiv="content-type" content="text/html; charset=utf-8">  
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>       
    <style type="text/css">    
    /* CSS Document */   
    /*PAGE LAYOUT*/
 0

© Stack Overflow or respective owner

Related posts about cakephp