Точки останова отладчика Chrome javascript ничего не делают?
Я не могу понять инструмент отладки Chrome.
У меня хромированная версия 21.0.1180.60 м.
Шаги, которые я предпринял:
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.Я также заметил, что Watch Expressions тоже не работают. Мне постоянно говорят, что переменная, которую я хочу посмотреть, не определена.
Дальнейшее тестирование показало, что это мой код, который приводит к сбою точки останова. Кажется, что он завершается ошибкой в строке "$ (" # frmVerification "). Submit (function () {". Он не входит в точки останова внутри этой функции ().
Ниже это:
//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;
});
});