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;
}
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With