views:

42

answers:

2

My questions are:

  1. How can I know if the AJAX is working properly?.
  2. How can I retrieve the sent data in the controller in CakePHP?

My code is:

function checkLength(obj,url){
    alert("URL="+url+"   OBJ="+obj); 

    if(obj)
    {
        var params = 'query='+obj; 
        var myAjax = new Ajax.Request(url,{method: 'post',parameters:params,onSuccess: loadResponse}); 
    }
}
A: 

I tend to use Firebug to debug my ajax, as the Net tab works fantastically for seeing outgoing requests along with what is returned from your script.

Check it out, http://getfirebug.com/

DavidYell
A: 

@Rajesh If you want to receive the data send from this function to the back end you can view the content using the $_POST[] array object in u r cakephp or the data[field] attribute of the controller

satts
this is ok whether there is any required file that should be included in program i heard abt prototype.js and JSON.js
rajesh
Are you trying to use Ajax without any javascript?
DavidYell
i just wanna to send the value to url and catch in controller file for that i used ajax
rajesh
@RajeshI believe Prototype is already included in u r workspace based on the code that you have mentioned.
satts