phpjqueryajaxjson

How to debug Ajax request and related PHP code?


What is the best debug tool to debug AJAX requests, and see what happens to my PHP code which is triggered via AJAX? 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;
}

Solution

  • The simple way is view the trigger in browser itself.

    Open the website in chrome browser

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