I can't seem to figure out the Chrome debugging tool.
I have chrome version 21.0.1180.60 m.
Steps I took:
- I pressed ctrl-shift-i to bring up the console.
- Clicked on Sources then select the relevant javascript file that I want to debug.
- I set breakpoints where I want the code to stop by putting a blue tag on the gutter next to the line on the left.
- I clicked on the button on my webpage (which is a php rendered page) that initiates the javascript code.
- The code ran successfully without stopping.
I also noticed that the Watch Expressions don't work either. It keeps telling me that the variable that I want to watch is undefined.
Further testing found that it's my code that's causing the breakpoint to fail. It seems that it fails on the $(#frmVerification).submit(function(){ line. It doesn't step into the breakpoints inside that function().
Below is the:
//function to check name and comment field
var test = this is a test;
var test2 = this is another test;
function validateLogin(){
//if(userEmail.attr(value) && userPass.attr(value))
return true;
//else
//return false;
}
//onclick on different buttons, do different things.
function ajaxRequest(){
}
$(document).ready(function(){
//When form submitted
$(#frmVerification).submit(function(){
var username = $(#username);
var token = $(#token);
var action = $(#action);
var requester = $(#requester);
if(validateLogin()){
$.ajax({
type: post,
url: verification.php,
data: username=+username.html()+&token=+token.val()+&action=+action.val()+&requester=+requester.val(),
success: function(data) {
try{
var jsonObj = $.parseJSON(data); //convert data into json object, throws exception if data is not json compatible
if(jsonObj.length > 0){//if there is any error output all data
var htmUl = $('<ul></ul>');
$.each(jsonObj, function(){
htmUl.append('<li>' + this + '</li>');
});
$(#errOut).html(htmUl);
}else{
alert(Your account is now activated, thank you. If you have already logged in, press OK to go to the home page. If not, you must log in first.);
window.location.replace(home.php);
}
}
catch(e){//if error output error to errOut]
$(#errOut).html(PHP module returned non JSON object: <p>+data+</p>);
}
}
});
}
else alert(Please fill UserName & Password!);
return false;
});
});