我正在使用jQuery Nestable插件为网站创建菜单编辑器.在用户点击菜单项并更改其位置后,我尝试获取商品ID和子项.
问题:我不知道如何获取ID和子项并更新到数据库.
这是jQuery Nestable插件
<script>
$(document).ready(function () {
var updateOutput = function (e) {
var list = e.length ? e : $(e.target), output = list.data('output');
if (window.JSON) {output.val(window.JSON.stringify(list.nestable('serialize')));//, null, 2));
} else {
output.val('JSON browser support required for this demo.');
}
console.log(list.nestable('serialize'));
console.log(window.JSON.stringify(list.nestable('serialize')));
};
$('#nestable').nestable({
group: 1,
maxDepth: 7,
}).on('change', updateOutput);
updateOutput($('#nestable').data('output', $('#nestable-output')));
});
</script>
Run Code Online (Sandbox Code Playgroud)
这是菜单的HTML
<div class="cf nestable-lists">
<div class="dd" id="nestable">
<ol class="dd-list">
<li class="dd-item" data-id="1"> <div class="dd-handle">Item 1 when …Run Code Online (Sandbox Code Playgroud) 我正在尝试在下面的命令中安装并在mac osx 10.12.15上运行Reaction
npm install -g reaction-cli reaction init cd reaction reaction
然后我得到了以下错误我刚刚与Reactjs开发人员新鲜,所以它只是紧张.它只是与包版本兼容,但我怎么能解决这个问题
=> Started proxy.
=> Started MongoDB.
/Users/sopheak/.meteor/packages/templating-compiler/.1.3.2.1411czp++os+web.browser+web.cordova/plugin.compileTemplatesBatch.os/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:190
throw error;
^
Error: ENFILE: file table overflow, scandir '/Users/sopheak/Documents/cam/react/reaction/packages/gridfs'
at Error (native)
at Object.fs.readdirSync (fs.js:808:18)
at Object.wrapper (/tools/fs/files.js:1586:35)
at readDirectory (/Users/sopheak/.meteor/packages/meteor-tool/.1.5.0.15auley++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/fs/watch.js:338:26)
at Watcher._fireIfDirectoryChanged (/Users/sopheak/.meteor/packages/meteor-tool/.1.5.0.15auley++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/fs/watch.js:490:23)
at /Users/sopheak/.meteor/packages/meteor-tool/.1.5.0.15auley++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/fs/watch.js:747:12
at Array.forEach (native)
at Function._.each._.forEach (/Users/sopheak/.meteor/packages/meteor-tool/.1.5.0.15auley++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
at Watcher._checkDirectories (/Users/sopheak/.meteor/packages/meteor-tool/.1.5.0.15auley++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/fs/watch.js:736:7)
at new Watcher (/Users/sopheak/.meteor/packages/meteor-tool/.1.5.0.15auley++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/fs/watch.js:435:10)
at setupClientWatcher (/tools/runners/run-app.js:800:23)
at [object Object]._.extend._runOnce (/tools/runners/run-app.js:811:7)
at [object Object]._.extend._fiber (/tools/runners/run-app.js:890:28)
at /tools/runners/run-app.js:417:12
Run Code Online (Sandbox Code Playgroud) 我使用的jQuery插件嵌套与Codeigniter3创建5级网站,供用户一个很好的解决方案可以单调而下降到改变的菜单项的水平和位置的菜单.但是我的下面的功能只能创建第一级菜单,当我更改为菜单项的子级别(2,3,4,5)时,它对我不起作用.
问题我无法将菜单项从第一级更改为另一级.我不能逆转的菜单项回到父母,如果我已经改变了它是一个孩子的任何的父母.无论Jquery Nestable如何工作都会如此.
以下函数用于将菜单项更新为依赖于菜单列的数据库,如:id,parent_id,m_order.
此函数将通过foreach和array_key_exists检查$ List数组内部,如下所述:
而这个if($ parent_id!= $ item ['id']){...}将不会更新parent_id作为父项的当前id.
public function savelist() {
if ($this->input->post('list')) {
$this->do_update($this->input->post('list'));
}
}
public function do_update($list, $parent_id = 0, &$m_order = 0) {
foreach …Run Code Online (Sandbox Code Playgroud)我试图在jQuery AJAX调用成功时将5行数据库(MySQL)中的数据显示到表行.数据JSON格式正确.
问题:我无法弄清楚所有这些行.我只能获得一行但是console向我展示了JSON格式化的所有行.
$.ajax({
url: '<?php echo base_url('ads/select_post'); ?>',
data: {},
dataType: "json",
cache: false,
success: function (data) {
$.each(data, function (i, val) {
console.log(val.name);
$("#name").html(val.name);
$("#price").html(val.price);
$("#addr").html(val.addr);
$("#des").html(val.des);
$("#viewed").html(val.viewed);
$("#status").html(val.status);
});
}
});
Run Code Online (Sandbox Code Playgroud)
控制台输出:
[{"name":"dfasdfas","price":"0","addr":"dfasdfas","des":"sadfdfasdfasdf","viewed":"0","img":"","status"
:"1"},{"name":"Heng","price":"0","addr":" dflkas;df","des":"asdfasdf"
,"viewed":"0","img":"","status":"1"},{"name":"asdDasdA","price":"0","addr":"asdADasd","des":"ASDasdASD"
,"viewed":"0","img":"","status":"1"},{"name":"asdfas","price":"0","addr":"fasdfas","des":"dfasdf","viewed"
:"0","img":"","status":"1"},{"name":"asdf","price":"0","addr":"asdfasdfas","des":"asdfasdfasdf","viewed"
:"0","img":"","status":"1"}]
Run Code Online (Sandbox Code Playgroud)
HTML 我要发送数据的表,
<tbody id="items">
<tr>
<td>1</td>
<td><a><div id="name"></div> </a></td>
<td><a><div id="price"></div> </a></td>
<td><a><div id"addr"></div></a></td>
<td><div id="des"></div> </td>
<td><a><div id="viewed"></div></a></td>
<td><a><div id="status"></div></a></td>
</tr>
Run Code Online (Sandbox Code Playgroud)
请指教.
我试图从表Teller中获取所有列名
功能:
public function getTableColumns($tables)
{
return DB::select(DB::raw('SELECT
COLUMN_NAME,
DATA_TYPE,
COLUMN_DEFAULT
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
table_name = `Teller`'));
}
Run Code Online (Sandbox Code Playgroud) 我正在创建使用Codeigniter和jquery Ajax自动上传图像的功能.用户将从他们的计算机中选择他们的图像,然后Ajax将通过Post发送到服务器.
问题:图像无法上传到服务器,在Ajax响应后,我得到了一个空的图像属性.似乎我的表格无效,但我仍然无法找到解决方案.
结果: Ajax响应后,我的res变量无法获取任何数据.
这是我的控制器
public function upload() {
$this->load->helper(array('form', 'url'));
$config['upload_path'] = './uploads/';
$config['image_library'] = 'gd2';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
$token = $this->security->get_csrf_hash();
$data = array();
$res = FALSE;
if (!$this->upload->do_upload('userfile')) {
// $data = $this->upload->data();
$res = FALSE;
} else {
$res = TRUE;
$this->upload->do_upload('userfile');
$data = $this->upload->data();
}
echo json_encode(array('res'=>$res,'img_pro'=>$data,'token'=>$token));
}
Run Code Online (Sandbox Code Playgroud)
这是我的表格
<?php …Run Code Online (Sandbox Code Playgroud) 我是通过使用curl_setopt PHP和Ajax查询来自另一个服务器的数据 我已经测试了我的下面的功能它是工作但它似乎不够顺利,因为有时当我尝试刷新和互联网有点大慢我永远不会得到数据.当我在Firefox中检查firebug时,我发现如下json响应.
"<html><head>
<meta http-equiv="refresh" content="0;url=http:MyPartnerWebsite!queryLuckNumberRecordByPeriods.action?gwqqnhmpepceiqqn">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
</head><body></body></html>
"
Run Code Online (Sandbox Code Playgroud)
*我现在被卡住了,因为我不知道如何应对这个问题*
private function http_code() {
$ch = curl_init();
if (!$ch) {
die("Couldn't initialize a cURL handle");
}
$ret = curl_setopt($ch, CURLOPT_URL, "http://Mypartnerwebsite!queryLuckNumberRecordByPeriods.action");
$ret = curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$ret = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ret = curl_setopt($ch, CURLINFO_PRETRANSFER_TIME, 0.1);
$ret = curl_setopt($ch, CURLINFO_HTTP_CODE, true);
$ret = curl_setopt($ch, CURLOPT_PRIVATE, false);
$ret = curl_setopt($ch, CURLOPT_TIMEOUT, 60);
$ret = curl_exec($ch);
$data;
$res;
if (empty($ret)) { …Run Code Online (Sandbox Code Playgroud) 我想在 Eloquent 中使用 WhereIn 方法,但现在它的工作方式如下
留言: Call to undefined method Illuminate\Database\Query\JoinClause::whereIn()
Class Notificatin extends Model{
public function getNotification($user_id)
{
$this->_data = self::select('*')
->join('user_permission', function($join){
$join->on('n_user_id','=','user_id')->whereIn('permission_id',array(90,91,92,93));
})
->get();
if (count($this->_data)) {
return $this->_data;
} else {
return $this->_data;
}
}
}
Run Code Online (Sandbox Code Playgroud) 我想在一列存储阵列类型的数据库,然后回用在哪里比较n_group_code_id之间阵列($ GID) 功能如下.
CREATE TABLE IF NOT EXISTS `tb_notification` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`n_user_id` int(10) NOT NULL,
`n_group_code_id` varchar(30) NOT NULL,
`n_source_id` int(10) NOT NULL,
`n_activity_type` varchar(100) NOT NULL,
`n_create_times` datetime NOT NULL,
`n_description` varchar(160) NOT NULL,
`n_status` int(2) NOT NULL,
`url` varchar(200) NOT NULL,
`updated_at` datetime NOT NULL,
`created_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=542 ;
--
-- Dumping data for table `tb_notification`
--
INSERT INTO `tb_notification` (`id`, `n_user_id`, …Run Code Online (Sandbox Code Playgroud) 我想将 google plus 中的图像保存为下面的 url,它在本地计算机上也能正常工作,但在上传到 ubuntu14 时出现以下错误。
$image = Image::make('https://lh6.googleusercontent.com/-Gcp_Wjj7yA0/AAAAAAAAAAI/AAAAAAAAAB8/hl1xcz4FnEI/photo.jpg')
->resize(100, 100)->save(public_path('image/userface/fuck.jpg'));
Run Code Online (Sandbox Code Playgroud)
错误
Unable to init from given url
Run Code Online (Sandbox Code Playgroud) php ×7
jquery ×5
ajax ×3
javascript ×3
laravel-5 ×3
codeigniter ×2
json ×2
laravel ×2
arrays ×1
eloquent ×1
intervention ×1
meteor ×1
node.js ×1
npm ×1
reactjs ×1