0

I am using netbeans 6.9 and use xdebug to step through my php file which is great. however, I have been using ajax/xmlhttprequest in my project and i have a hard time debugging that. i did some research and came across firebug/firephp and read through a little. i am not against learning new tools but if it can be integrated into the ide i am currently using, it will be more efficient and effective.

so, to provide more example, suppose on my index.php i have this:

<button onclick="getTweet()">Get Tweets!</button>

the getTweet() function reside in a .js file

function getTweet(){
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function(){
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
             // do something here
        }
    }
    xmlhttp.open("GET", "getTweet.php?q="+$phpVars,true);
    xmlhttp.send();
}

getTweet.php goes out and does a twitter search:

$search = "http://search.twitter.com/search.atom?q=" . $q . "";
$tw = curl_init();
curl_setopt($tw, CURLOPT_URL, $search);
curl_setopt($tw, CURLOPT_RETURNTRANSFER, TRUE);
$twi = curl_exec($tw);
$search_res = new SimpleXMLElement($twi);

Now, i am new to web development, php, js, ajax, html, xml, json, netbeans. I literally am learning all of this in the past 3.5 months so i'm new and need clear instructions.

In getTweet.php, i can insert breakpoints in netbeans BUT...when i click the html button which triggers getTweet() from .js file which makes a xmlhttprequest, the debugger in netbeans does not trigger. Being able to see the variables and its outputs (XML, JSON, etc...) helped me tremendously in learning this stuff so I would like to be ale to see vars in getTweet.php such as $twi,$search_res,etc...

Thanks for the advice!!!

PS: Will firebug work for what I am trying to achieve? I am learning slowly and don't want to pile up too many things at once. Thanks!

2 Answers 2

1

In order to get the debugger triggered in getTweet.php, you need to indicate to xdebug that the debugger is listening by sending the XDEBUG_SESSION_START parameter. Update the code in getTweet() to have the following:

xmlhttp.open("GET", "getTweet.php?XDEBUG_SESSION_START=netbeans-xdebug&q="+$phpVars,true);
Sign up to request clarification or add additional context in comments.

Comments

0

Xdebug will only catch server-side events, meaning you can't step through your client-side script with it. However, Netbeans does have the ability to step through Javascript (I haven't actually tried it myself as I use Firebug to step through script).

Here's some documentation on setting up script debugging in your Netbeans project.

1 Comment

javascript debugging on netbeans have been disabled for 6.9 which is the latest and the version i am using according to this forum post: forums.netbeans.org/topic28527.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.