0

I want to use database data and send it to a PHP script using JQuery's AJAX. How would I achieve this?

Here's the code so far:

function update(id) {
  $("#update").click(function() {
    $.ajax({
      type: 'POST',
      url: '<?= base_url("event/update_event_view"); ?>',
      data: {'id': id},
      dataType: 'json',
      success: function(retval) {
        $('#display').hide();
        $('#up').show();
        $('#up').html(retval[0]);
      }
    });
  });
}
evamvid
  • 831
  • 6
  • 18
  • 40
Shadow
  • 35
  • 6

1 Answers1

0

Try this way:

function update(id) {
      $.ajax({
          type: 'POST',
          url: "@Url.Action("update_event_view", "event")",
          data: {'id': id},
          dataType: 'json',
          success: function(retval) {
                 $('#display').hide();
                 $('#up').show();
                 $('#up').html(retval);
           }
      });
 }