$.ajax({
method: "post"
, url: "save.php"
, data: "id=453&action=test"
, beforeSend: function(){
}
, complete: function(){
}
, success: function(html){
$("#mydiv").append(html);
}
});
Run Code Online (Sandbox Code Playgroud)
我已经将方法类型设置为post但在Save.php中我只是在$_GET或$_REQUEST不在中获取值$_POST.
我的表格如下:
<form method="post" id="myform" action="save.php">
Run Code Online (Sandbox Code Playgroud)
它无法正常工作,在这里查看并在Google上尝试添加 enctype
<form method="post" id="myform" action="save.php" enctype="application/x-www-form-urlencoded">
Run Code Online (Sandbox Code Playgroud)
但还是$_POST空的?
我如何使其工作?
我需要将一些值存储在beforeCreate稍后我需要的Vue Component 钩子中beforeDestroy.事情是(或者至少是我所理解的)beforeCreate钩子无法获得被动反应data.
由于我不需要这些值,但beforeDestroy我不介意它们不被反应,所以我很擅长.但最后,当我尝试:
Vue.component('my-component', {
data: function() { return { msg: "I'm a reactive value." }},
template: '<div><div>{{ msg }}</div> <div>{{value}}</div> <button @click="onClick">Click Me</button></div>',
beforeCreate: function() { this.value = "I was declared before data existed." },
methods: {
onClick: function(event) {
this.msg += " So, I respond to changes.";
this.value += " But I'm still reactive... (?)";
}
}
});
var app = new Vue({
el: '#app',
});Run Code Online (Sandbox Code Playgroud)
<script …Run Code Online (Sandbox Code Playgroud)有人可以解释会话变量的位置吗?
我在控制器的header.php中添加了一些会话变量,例如:
$this->session->data['day']=date("d",strtotime($row['startdate']));
Run Code Online (Sandbox Code Playgroud)
这工作加载网站的时候,当我点击一个产品,所有的变量都消失了,除了[language],[currency]并且[cart]它们由Opencart的设置.
我想有是我设置的变量,或其他文件或文件控制器[language],[currency]以及[cart]设置,但我不能找到它.
提前致谢.
我知道我的问题标题可能会令人困惑(我知道对象属性没有顺序),因为我已经提出了一个解决方案,所以为了避免创建XY 问题,让我首先解释一下我的目标:
我需要渲染N 个单词表,这些单词按单词长度分组,并且(这是棘手的事情)按长度降序排列。就像是:
Words with length 4
===================
abcd | other fields
abce | other fields
abcf | other fields
Words with length 3
===================
abc | other fields
abd | other fields
abe | other fields
Words with length 2
===================
...
Run Code Online (Sandbox Code Playgroud)
我正在从 API 获取单词列表,无需任何分组,所以我现在正在做的是:
let grouped = {};
// Assume words is an Array of words of multiple lengths
words.forEach(w => {
if (typeof grouped[w.length] === 'undefined')
grouped[w.length] = [];
grouped[w.length].push({'word': …Run Code Online (Sandbox Code Playgroud) 我正在使用gtag.js在 Vue.js SPA 中设置两个不同的跟踪器。我正在定义我index.html喜欢的跟踪器:
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXX-1', {
'send_page_view': false
});
gtag('config', 'UA-XXXXXXXX-2', {
'send_page_view': false,
'custom_map': {
'dimension1' : 'my_custom_dimension'
}
});
</script>
Run Code Online (Sandbox Code Playgroud)
然后,在我的路由器afterEach导航守卫中,我执行以下操作:
router.afterEach((to, from) => {
gtag("event", "page_view", {
send_to: 'UA-XXXXXXXX-1'
});
gtag("event", "page_view", {
send_to: 'UA-XXXXXXXX-2',
my_custom_dimension: 'custom_value'
});
}
});
Run Code Online (Sandbox Code Playgroud)
没有涉及其他 GA 代码,但是当我查看 GA 调试扩展日志时,对于单个页面加载,我看到它创建了两个跟踪器,但随后我也收到一条警告消息:
analytics_debug.js:24 忽略创建重复跟踪名称的请求。
我找不到有关该警告的任何明确信息,到目前为止我一直无法理解为什么会发生这种情况以及如何避免它。因此,任何避免这种情况的帮助将不胜感激!
我已将Angular 2升级为Angular 4.当我运行我的项目时,我面临以下错误.
node_modules/@ angular/platform-browser/platform-browser"'没有导出成员'AnimationDriver'.
我有一个对象数组。像这样的东西:
$my_array = [
(object) ['name' => 'name 0'],
(object) ['name' => 'name 1'],
(object) ['name' => 'name 2'],
];
Run Code Online (Sandbox Code Playgroud)
我想将其简化为所有name属性的串联,例如:
姓名 0 / 姓名 1 / 姓名 2
一种方法是:
$result = [];
foreach ($my_array as $item) {
$result[] = $item->name;
}
echo implode(' / ', $result);
Run Code Online (Sandbox Code Playgroud)
但我更喜欢更紧凑的东西,比如使用array_map:
implode(' / ', array_map(function($item) {
return $item->name;
}, $my_array ));
Run Code Online (Sandbox Code Playgroud)
鉴于事实上我想减少和数组到一个我认为它会更干净的字符串,array_reduce但我能提出的唯一解决方案是:
array_reduce($my_array, function($carry, $obj) {
return empty($carry) ? $obj->name : $carry .= …Run Code Online (Sandbox Code Playgroud) 向分类页面添加上下投票功能。使用 Laravel 和 Vue。
我得到的错误是:
(1/1) FatalThrowableError 类型错误:传递给 Hustla\Http\Controllers\ListingVoteController::show() 的参数 2 必须是 Hustla\Listing 的一个实例,给出的字符串
我已经包含了 vue 文件、投票控制器、列表模型和路由。我希望有人可以帮助我。
上市模式
public function votesAllowed()
{
return (bool) $this->allow_votes;
}
public function commentsAllowed()
{
return (bool) $this->allow_comments;
}
public function votes()
{
return $this->morphMany(Vote::class, 'voteable');
}
public function upVotes()
{
return $this->votes()->where('type', 'up');
}
public function downVotes()
{
return $this->votes()->where('type', 'down');
}
public function voteFromUser(User $user)
{
return $this->votes()->where('user_id', $user->id);
}
Run Code Online (Sandbox Code Playgroud)
投票控制器
public function show(Request $request, Listing $listing)
{
$response = [
'up' => …Run Code Online (Sandbox Code Playgroud) 我的目标是在每四个帖子后打印一些额外的HTML.
以下代码有什么问题
<?php while ( have_posts() ) : the_post(); ?>
<?php wc_get_template_part( 'content', 'product' ); ?>
<?php
$posts = $wp_query->post_count;
if ( $posts == 4 ) {
echo '<div class="clearfix"></div>';
}
?>
<?php endwhile; // end of the loop. ?>
Run Code Online (Sandbox Code Playgroud)