Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best debug tool to debug Ajax request in PHP [closed]

What is the best debug tool to debug AJAX request in PHP? I want to check whether the method in the class.php has been fired when the AJAX function is calling.

Eg:

$.ajax({
    url: 'classes/MyClass.php/GetItems',
    data: {
        'catgry': cat
    },
    dataType: 'json',
    success: function (data) {
        alert("data recived!");
    },
    error: function (jqxhr, textStatus, errorThrown) {
        alert("error");
    }
});

MyClass.php

public function GetItems($catgry) {
   $ret = $itmObj->GetItemsByCat($catgry);
   return $ret;
}
like image 877
tishantha Avatar asked Sep 02 '13 08:09

tishantha


3 Answers

The simple way is view the trigger in browser itself.

Open the website in chrome browser

  • Click F12.

  • Click on Network tab. Reload the page to find all the files getting loaded.

  • select the MyFile.php and then click on the response tab to see ur respone.

You can also see other details like time taken for response, initiator file etc. by this method.

like image 71
Ganesh Babu Avatar answered Sep 21 '22 17:09

Ganesh Babu


As far as I understood the question here is how to debug the PHP code, not the request itself. The request is easily viewable inside the developer tools of your browser. The only one method which I can come with is to add the debugging information into the response to the browser. I.e. to use the response as a feedback.

like image 36
Krasimir Avatar answered Sep 20 '22 17:09

Krasimir


I am using firefox console to see the ajax request. It is good. Even you can use 'Net' of firefox. Both are available by default in firefox.

like image 37
Manish Sahu Avatar answered Sep 23 '22 17:09

Manish Sahu