是否可以将AJAX PATCH请求设置为laravel,或者我是否仅限于POST?Laravel在输入隐藏字段中使用PATCH,但是,我没有使用表单元素 - 只是在单击时(通过AJAX请求)部分更新记录的按钮.
这条路线怎么样?
路由文件
Route::patch('questions/{id}', 'QuestionController@update')->before('admin');
我不确定laravel路由是否支持PATCH.
调节器
public function update($id) {
if (Request::ajax() && Request::isMethod('patch')) {
//partially update record here
}
}
Run Code Online (Sandbox Code Playgroud)
JS
$('div#question_preview <some button selector>').click(function (event) {
$.ajax({
url: 'questions/'+question_id,
type: 'PATCH',
data: {status: 'some status'}
});
});
Run Code Online (Sandbox Code Playgroud)
我只是想寻求清晰,谢谢!
我想创建一个启动超时的函数,但是如果再次调用该函数,则在计时器结束之前,取消原始调用并再次启动计时器.
我以为我能做到:
function setTimer() {
setTimeout(() => {
// do something
}, 3000)
}
Run Code Online (Sandbox Code Playgroud)
...但是这不起作用,因为每次运行setTimer()时,它都不会取消原始调用.
谁能指出我正确的方向?
我知道这段代码实际上会将数据写入ds:[100h]
mov [100h], ax
Run Code Online (Sandbox Code Playgroud)
但是,如何在100H不使用段基的任何段寄存器的情况下直接写入线性地址?
嘿,我想使用 lodash 计算对象数组中一个属性的总和
假设对象数组看起来像这样......
salary":[{
"bills":[{"electricity":300,"milk":500},
{"electricity":240,"milk":200},
{"electricity":800,"milk":900}]
}]
Run Code Online (Sandbox Code Playgroud)
我想使用 lodash 计算该对象的“牛奶”总和。
这个程序告诉给定的输入是否是质数,但我不明白 for 循环在这里做什么?它没有括号,也没有语句。
int main(void)
{
int n;
printf("Enter an integer number (> 1): ");
if (scanf("%d", &n) != 1 || n <= 1) {
printf("Invalid input. Quit!\n");
return -1;
}
int d;
for (d = 2; n % d != 0; d++)
;
if (d == n)
printf("%d is prime\n", n);
else
printf("%d divides into %d\n", d, n);
return 0;
}
Run Code Online (Sandbox Code Playgroud) Errors are illegal start of an expressionerror: not a statement';' expected我在takeStix()中收到有关if else语句的错误.
private int numStix;
public int getNumStix() {return numStix;}
public boolean takeStix(int number) {
( number <= 3 && number <= getNumStix() ) ? return true : return false;
}
Run Code Online (Sandbox Code Playgroud) 请向我解释为什么我不能将匿名函数作为str_pad()的参数.
例如:
str_pad(function ($num) {
return ($num > 5) ? "greater" : "less than";
}, 57, '_');
Run Code Online (Sandbox Code Playgroud)
由于函数返回一个字符串,为什么我不能这样做呢?