没有在javascript函数中定义

时间:2016-04-24 03:20:25

标签: jquery ajax

我正在调用函数,但是我收到错误“未定义”。我使用php进行简单的编码。我该如何解决呢? 谢谢。

这里是脚本html

<div class="modal fade" id="contohModal<?php echo $value->kategori_id; ?>" tabindex="-1" role="dialog" aria-labelledby="modalku">
            <div class="modal-dialog" role="document">
              <div class="modal-content">
                <div class="modal-header">
                  <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                  </button>
                  <h4 class="modal-title" id="modalku">Modal Edit<?php echo $value->kategori_id; ?></h4>
                </div>
                <div class="modal-body">
                  <form method="post">
                    <div class="form-group">
                      <label>Kategori</label>
                      <input type="text" id="kt<?php echo $value->kategori_id?>" value="<?php echo $value->kategori_laporan; ?>" class="form-control">
                      <input type="hidden" name="kategori_id" id="kategori_id" value="<?php echo $value->kategori_id; ?>">
                    </div>
                  </form>
                </div>
                <div class="modal-footer">
                  <button onclick="updateData(<?php echo urlencode($library->hash_url('enkripsi', $value->kategori_id)); ?>)" name="<?php echo $value->kategori_id; ?>" value="<?php echo $value->kategori_id; ?>" id="updateKategori" type="button" class="btn btn-primary btn-flat" data-dismiss="modal">Update</button>
                </div>
              </div>
            </div>

这里是我的脚本ajax jquery

function updateData(id)
{
    var id = id;
    var kategori = $("#kt"+id).val();
    var updateKategori = $("#updateKategori").val();
    var datas = "id="+id+"&kategori="+kategori+"&updateKategori="+updateKategori;
    $.ajax({
        url: "_controllers/proses-kategori.php",
        type: "POST",
        data: datas,
        success: function() {
            alert("Berhasil");
        }
    });
}

0 个答案:

没有答案