┼Żygimantas Pranka ┼Żygimantas Pranka - 2 years ago 102
Javascript Question

Where to put Error Alert in my JS

Hi there! So I wanted to ask where I need to place Error Alert code in this JS and if it is of any use in such JS.

$(document).ready(function () {
$.get("ImagePreview?b_id=<%=id%>", function (responseJson) {
var $select = $("<div>").addClass("galleria").appendTo($("#imgas"));
$.each(responseJson, function (index, item) {
$("<img />").attr("src", item).appendTo($select);

Answer Source
  • Put an alert every odd line like alert("A"), alert("B") etc
  • Refresh the page
  • Remove every alert from your code and keep the one you like best

P.S: if you want to test the actual responseJson than alert is a bad idea.
Use console.dir(responseJson); inside your AJAX function.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download