【问题标题】:How to convert my get request to post request如何将我的获取请求转换为发布请求
【发布时间】:2015-07-12 17:28:09
【问题描述】:

我正在使用下面的脚本

  $(document).ready(function() {
    $("#test-list").sortable({
      handle : '.handle',
      start: function(){
          $("#success-result").html("loading....");
      },
      update : function () { 

          var order = $('#test-list').sortable('serialize');
        $("#success-result").load("<?php echo base_url('explorer/processSortable'); ?>?"+order);
      }
    });

现在我想用 post 方法向我的 url 发送请求。我该怎么做。

【问题讨论】:

  • 不要在 javascript 代码中混合 php 代码,在你的 js 代码之上做一些类似 var url = "&lt;?php echo base_url('explorer/processSortable'); ?&gt;?"; 的事情

标签: javascript arrays ajax codeigniter


【解决方案1】:

jquery 加载函数是一种从服务器获取内容的简写方法。默认情况下,如果数据作为对象提供,则使用 POST 方法;否则,假定为 GET。

改用 $.post:

$.post("<?php echo base_url('explorer/processSortable'); ?>?"+order, function( data ) {
  $( "#success-result" ).html( data );
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-08
    • 2020-09-19
    • 1970-01-01
    • 2016-04-12
    • 2020-02-26
    • 2019-06-28
    • 2020-04-02
    • 1970-01-01
    相关资源
    最近更新 更多