我想通过 id 检索一个元素。
在我的刀片文件中:
{{ $auctionStatuses }}
Run Code Online (Sandbox Code Playgroud)
这输出:
[
{
"id":1,
"name":"Awaiting customer action",
"created_at":"2018-10-04 10:14:08",
"updated_at":"2018-10-04 10:14:08"
},
{
"id":2,
"name":"Transfer in progress",
"created_at":"2018-10-04 10:15:11",
"updated_at":"2018-10-04 10:15:11"
},
{
"id":3,
"name":"Completed",
"created_at":"2018-10-04 10:15:14",
"updated_at":"2018-10-04 10:15:14"
}
]
Run Code Online (Sandbox Code Playgroud)
我想在通过 id 字段引用时输出名称
由于一些数据来自 mongodb,我无法使用标准关系
我已经尝试过这个{{ $auctionStatuses['3'] }}
,但显然那不存在。
我想理想情况下,我想做这样的事情
{{ $auctionStatuses[*]->id['3']->name }}
有没有办法做我需要的事情,而不循环遍历 json 数组?
我在尝试转义几个引号时遇到了麻烦。
这是我的代码:
var somevalue = "test";
return $("<li onclick='document.getElementById(\"AddGenre\").value = " + '\'' + somevalue + '\'' ";'><div><img src='" + item.img + "'><span>" + somevalue + "</span></div></li>").appendTo(ul);
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
参数列表后未捕获到的SyntaxError:缺少)
我有以下共享相同的单选按钮name:
<div id="main_div">
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="radio1">
<input type="radio" id="radio1" class="mdl-radio__button" name="somename" value="1" checked>
<span class="mdl-radio__label">Radio 1</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="radio2">
<input type="radio" id="radio2" class="mdl-radio__button" name="somename" value="2">
<span class="mdl-radio__label">Radio 2</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="radio3">
<input type="radio" id="radio3" class="mdl-radio__button" name="somename" value="3">
<span class="mdl-radio__label">Radio 3</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="radio4">
<input type="radio" id="radio4" class="mdl-radio__button" name="somename" value="4">
<span class="mdl-radio__label">Radio 4</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="radio5">
<input type="radio" id="radio5" class="mdl-radio__button" name="somename" value="5">
<span class="mdl-radio__label">Radio 5</span> …Run Code Online (Sandbox Code Playgroud) 我试图通过ajax获得响应,我的代码(index.html):
<button id="register">Register</button>
<p id="result">xxx</p>
<script>
$("#register").click(function(){
$.ajax({
url:'registration.php',
type: 'POST',
success:function(response){
$("#result").html(response)
}
})
})
</script>
Run Code Online (Sandbox Code Playgroud)
和php(registration.php):
<?php
echo "yyy"
?>
Run Code Online (Sandbox Code Playgroud)
我正在使用xampp,得到响应,但它会立即从页面消失。xxx再次出现在p标签中,有人知道这是什么原因吗?谢谢