【问题标题】:jQuery load missing argumentjQuery 加载缺少的参数
【发布时间】:2015-09-08 00:55:56
【问题描述】:

我有这样的代码

function firstload(maxid, next_page, results, animation_image, btn_load, url, endpoint) {
        var a = ''+maxid+'';
        var b = ''+next_page+'';
        var c = ''+endpoint+'';

        $('#'+results+'').load('<?php echo base_url()?>create/firstload', { max_id: a, next_page: b, endpoint: c }, function() { 
            var nextpage = $('#'+next_page+'').val();
            if (nextpage != 0) { $('.'+btn_load+'').show(); }
            else {  $('.'+btn_load+'').hide();  }
            $('.'+animation_image+'').hide();
        });
    }

firstload('max_id','nextpage','results','animation_image','load_more','load','get_user_recent');

和这样的 php 后端:

function firstload($max_id, $next_page, $endpoint) {
 echo '<p> '$max_id' </p> //just a piece of code
}

[编辑] 我在函数上添加了一些代码。 我希望前端的 id #result 包含来自 firstload 函数的“max id”。

但它返回一些错误:

Severity: Warning
Message: Missing argument 1 for Create::firstload()
Filename: controllers/Create.php
Line Number: 156

它也发生在论点 2 和 3 上。

我的代码有什么问题?

【问题讨论】:

  • 查看网络请求时看到了什么?
  • 这是一个 PHP 错误 - 您需要确保调用中的所有参数。
  • 您使用的是 PHP 框架吗?期望如何将参数传递给Create 控制器中的firstload 函数?
  • load()post 将对象传递给您的数据。我怀疑你不希望在服务器上发帖
  • 行号:156 是“function firstload($max_id, $next_page, $endpoint)”。所以我认为前端的变量没有传递到后端。

标签: javascript php jquery jquery-load


【解决方案1】:

&lt;?php ?&gt; 标记放在您要作为php 运行的代码周围。看起来你缺少这些标签,你打电话给firstload(...)

【讨论】:

  • 你把同名的javascript方法和php方法混淆了
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-09-21
  • 1970-01-01
  • 1970-01-01
  • 2018-09-23
  • 1970-01-01
  • 2016-01-01
  • 1970-01-01
相关资源
最近更新 更多