Click here to Skip to main content
15,894,180 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends,
Can anyone tell me, how can one debug javascript. I'm using VS 2008, 3.5 framework.
I tried by giving breakpoint, but in runtime javascript code is not getting debug.

Thanks in advance
Posted
Comments
dhage.prashant01 6-May-11 3:39am    
I'm trying out following
http://www.codeproject.com/Questions/191834/AutoComplete-using-Webservice-in-asp-net.aspx
using
http://www.roseindia.net/tutorial/ajax/jquery/autocomplete.html
as source.

To enable javascript debugging

goto browser

Tools-Internetoptions-advanced

After that uncheck
Disable script debugging(Internet explorer)


then Apply-ok
 
Share this answer
 
v2
Comments
dhage.prashant01 6-May-11 3:16am    
Any idea about firefox?
Ashishmau 6-May-11 3:18am    
Uncheck Disable script debugging(other)
dhage.prashant01 6-May-11 3:21am    
Actually, i was trying to fill following
<script type="text/javascript">
$(document).ready(function() {
$.ajax({
type: "POST",
url: "WebService.asmx/getClientName",
dataType: "json",
data: "{}",
contentType: "application/json; charset=utf-8",
success: function(data) {
if (data.length > 0) {
var datafromserver = data.d.split(",");
$('#suggestions').show();
$('#suggestionList').html(datafromserver);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
}
});
})
</script>

but suggestionList is not getting populated with data.
Ashishmau 6-May-11 3:32am    
Install Firebug in firefox and then debug and check
Make sure you have enabled javasctipt debugging in your browser. (For IE, Internet options -> Advanced)

Once you do that, you should be able to put breakpoints in the Javascript files.
In case, you are still facing issues, but keyword 'debugger' in the javascript method. When the method is executed, it will stop there.

Try!
 
Share this answer
 
As Javscript runs in your browser IMO it's simpler to just use the built in browser debugging capabilities rather than fiddle with getting it to work with VS.

For Firefox you can install 'Firebug'. After installing it you should see a little bug icon in the bottom right. You can click on that and it will open up a pane at the bottom, click on 'Script' (you may need to enable it first).

For Chrome, developer tools come installed standard: Wrench > Tools > Developer Tools. This will open a frame at the bottom of the page. Click on the 'Scripts' tab and it should show the scripts.

Both these options are pretty good giving you all the usual features you would expect from a debugger (watch expressions call stacks etc).

I believe the latest versions of IE also have similar capabilities built in but I do not have experience with them.
 
Share this answer
 
Two things you have to do to Debug the Javascript

1. Enable script debugging setting in your browser
2. put debugger; keyword in you javascript function

e.g
<script language="Javascript">
function showME()
{
  debugger;
  alert("test it");
}
</script>
 
Share this answer
 
Hope this Blog[^] might help you.
 
Share this answer
 
Comments
dhage.prashant01 6-May-11 3:13am    
I have been through blog earlier. But its not working, so decided to ask help over here.
[no name] 6-May-11 3:16am    
What error it shows, tell us so that we can help you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900