0

Trying to append data from this json file to html doc. This is the script:

$(document).ready(function() {
  $.ajax({
    type: "GET",
    url: "Beer.json",
    dataType: "json",
    success: processBeer,
    error: function(){ alert("error"); }
  });
  function processBeer(data){
    $(".box").append("Hello");
  }
}

This is the HTML:

<div class="box" id='d'>


</div>
9
  • The hello part is just to try and get anything to append to the box. Right now cant get anything to come up. Using chrome. Commented Jul 19, 2013 at 18:07
  • Could you look in the "Network" tab in your chrome debugger to see what the status of the AJAX request is Commented Jul 19, 2013 at 18:09
  • Yes, looks like it's probably a syntax error as Explsion Pills points out. Use the console in the debugger to track down your errors. Commented Jul 19, 2013 at 18:11
  • Are you using any debuggers? There are at least two errors I see (brackets, as well as not passing an argument to processBeer) that would be very evident if you were using Firebug, Chrome Developer Tools, etc. Commented Jul 19, 2013 at 18:12
  • Ok going to try and use the debugger, really new to HTML thanks a lot guys. I fixed the data passing problem and the brackets though. Commented Jul 19, 2013 at 18:30

1 Answer 1

1

You have a syntax error in the script that is probably preventing it from running altogether. You never close the paren for the .ready call

Sign up to request clarification or add additional context in comments.

Comments

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.