$ .ajax $未使用json定义

So I'm just trying to get this to work


    url: '/echo/json/', //Change this path to your JSON file.
    type: "post",
    dataType: "json",
    //Remove the "data" attribute, relevant to this example, but isn't necessary in deployment.
    data: {
        json: JSON.stringify([
            id: 1,
            firstName: "Peter",
            lastName: "Jhons"},
            id: 2,
            firstName: "David",
            lastName: "Bowie"}
        delay: 3
    success: function(data, textStatus, jqXHR) {

function drawTable(data) {
    var rows = [];

    for (var i = 0; i < data.length; i++) {


function drawRow(rowData) {
    var row = $("<tr />");
    row.append($("<td>" + rowData.id + "</td>"));
    row.append($("<td>" + rowData.firstName + "</td>"));
    row.append($("<td>" + rowData.lastName + "</td>"));

    return row;

the HTML

<!DOCTYPE html>
    <script src="js/kek.js"></script>
    <link rel="stylesheet" type="text/css" href="css/kek.css">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

<table id="personDataTable">
        <th>First Name</th>
        <th>Last Name</th>

I'm just trying to get this to post back, but every time i do it it just says "$" is not defined, i was hoping maybe it be the browser ( cause I've herd chrome does not like AJAX or JAON very much) so i changed it up. Still no good even Firefox is throwing this exception at me. So i went around looking in stackoverflow and i saw some solutions but i could come to understand how it could solve me problem. Im not too familiar with Js, AJAX, and JSON so i thought id post something and see if anyone could tell me what I'm doing wrong.

2015/05/27 20:25
  • json
  • ajax
  • javascript
  • jquery
  • 点赞
  • 收藏
  • 回答