【发布时间】: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