我想知道哪个协议用于向Android设备发送推送通知以及向GCM发送推送通知请求的协议.
无论是HTTP,HTTPS还是其他什么?
android protocols push-notification android-notifications google-cloud-messaging
如何使用Ajax将Javascript变量传递给Php并检索它们?
我正在使用Jquery Ui Slider,并且在每张幻灯片上我想将javascript滑块值传递给php,以便说明.
我没有(没有太多)Ajax的经验,非常感谢帮助.
这是我的滑块的样子:
$("#sliderNumCh").slider({
range: "min",
min: 0,
max: 20,
step: 1,
value: numbersOfChapters,
change : function(e, slider){
$('#sliderAppendNumCh').empty();
var i = 0;
var sliderValue = slider.value;
var getSliderVal = document.getElementById('sliderValue').value = sliderValue;
$.ajax({
type: 'POST',
url: '',
headers: {'X-Requested-With': 'XMLHttpRequest'},
data: {
value: getSliderVal
},
success: function (option) {
console.log(getSliderVal);
}
});
...
}
})
Run Code Online (Sandbox Code Playgroud)
我的路线示例:
编辑我的路线现在看起来像这样:
Route::post('edit/{productID}', ['as' => 'editProductPost', 'uses' => 'ProductController@editProduct']);
Run Code Online (Sandbox Code Playgroud)
编辑我尝试的内容:
url: '{{ route("editProductWeb") }}',
Run Code Online (Sandbox Code Playgroud)
并得到此错误:
Run Code Online (Sandbox Code Playgroud)POST http://localhost/myApp/public/product/edit/%7BproductID%7D 500 (Internal Server …
我想用图像魔法创建一个图像,它为我创建一个具有透明背景的文本。
到目前为止,我使用了这段代码,但它为我创建了黑色背景。
convert -debug annotate -size 720x480 -background none xc:black -fill white -stroke white -font Arial -pointsize 16 90x25 -draw "text 120,370 'move'"-font Arial -pointsize 16 50x25 -draw "text 250,370 'text'"-font Arial -pointsize 16 105x25 -draw "text 360,370 'images'"-font Arial -pointsize 16 115x25 -draw "text 500,370 'another text'" TextTransp.png
Run Code Online (Sandbox Code Playgroud)
该文件应为 .png。基本上应该有一个带有透明背景的白色文本。
如何将 javascript 变量作为 php 循环中的变量传递:
像这样的东西(显然不起作用):
var myJsVar = 100;
@for ($i = 0; $i<myJsVar; $i++)
... some code
@endfor
Run Code Online (Sandbox Code Playgroud)
此外我尝试用ajax解决这个问题:
/**
* Get slider value
*/
$.ajax({
type: 'GET',
url: myUrl,
data: myJsVar,
success: function (option) {
console.log(myJsVar);
}
});
Run Code Online (Sandbox Code Playgroud)
它返回我成功的函数,
此外,我在控制器中执行了此操作:
public function prod(Request $request)
{
if ($request->ajax()) {
$ajax = "AJAX";
dd($ajax);
} else {
$ajaxN = "NO Ajax";
dd($ajaxN);
}
}
Run Code Online (Sandbox Code Playgroud)
它不起作用。
我不确定如何继续,希望得到一些帮助。
我基本上想检查命令是否使用shell_exec
.
简单的功能:
public static function foo()
{
$command = "blabla";
shell_exec($command);
}
Run Code Online (Sandbox Code Playgroud)
编辑,我试过 M 先生的建议是这样的:
foreach($commands as $key => $value)
{
shell_exec($value, $output, $return);
}
Run Code Online (Sandbox Code Playgroud)
我得到这个错误:
未定义变量:输出
如何使用鼠标绘制使用3轴(x,y,z)的画布.
我知道可以在2轴上绘制画布,我已经成功完成了.
但我不知道如何在3轴(例如立方体)上绘制它.
下面显示了一些2d画布绘图功能
$(canvas).on('mousemove', function(e) {
mousex = parseInt(e.clientX-canvasx);
mousey = parseInt(e.clientY-canvasy);
if(mousedown) {
ctx.beginPath();
if(tooltype=='draw') {
ctx.globalCompositeOperation = 'source-over';
ctx.strokeStyle = 'black';
ctx.lineWidth = 3;
} else {
ctx.globalCompositeOperation = 'destination-out';
ctx.lineWidth = 10;
}
ctx.moveTo(last_mousex,last_mousey);
ctx.lineTo(mousex,mousey);
ctx.lineJoin = ctx.lineCap = 'round';
ctx.stroke();
}
last_mousex = mousex;
last_mousey = mousey;
//Output
$('#output').html('current: '+mousex+', '+mousey+'<br/>last: '+last_mousex+', '+last_mousey+'<br/>mousedown: '+mousedown);
Run Code Online (Sandbox Code Playgroud)
});
完整代码https://jsfiddle.net/ArtBIT/kneDX/.
但是如何添加az轴并绘制一个3d画布,例如一个立方体.
我设置了Laravel Passport,目前我正在尝试使用Post Route注册用户.我确实创造了一个RegisterController
内部Controllers/Api/Auth
.
因此,我创建了一个客户端表,看起来像用户表一样兴奋.如果我调用路由,则会创建客户端,但是我没有获得访问令牌或刷新令牌.
到我的控制器的路径如下(routes/api):
Route::post('register', ['as' => 'register', 'uses' => 'Api\Auth\RegisterController@register']);
Run Code Online (Sandbox Code Playgroud)
我的控制器看起来像这样:
<?php
namespace App\Http\Controllers\Api\Auth;
use App\Client;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Route;
use Laravel\Passport\Client as PClient;
use Illuminate\Http\Request;
class RegisterController extends Controller
{
private $client;
public function __construct() {
$this->client = PClient::find(1);
}
public function register(Request $request)
{
$this->validate($request, [
'name' => 'required',
'email' => 'required|email|unique:users,email',
'password' => 'required|min:6|confirmed'
]);
$client_user = Client::create([
'name' => request('name'),
'email' => request('email'),
'password' => bcrypt(request('password'))
]);
$params = [ …
Run Code Online (Sandbox Code Playgroud) 如何检查具有唯一ID的html标记是否存在两次或更多次?
我的伪代码:
if($('#myId') > 1) {
// exists twice
}
Run Code Online (Sandbox Code Playgroud) 如何仅使用Javascript删除background-color和opacity属性(无Jquery!).
我试过这个:
document.getElementById('darkOverlay').style.removeProperty("background-color");
document.getElementById('darkOverlay').style.removeProperty("opacity");
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
我构建了一个新的 Laravel 5.4 项目。
我试图在我的 api 路线中执行以下步骤,但不知何故它们不起作用。
在我的 app.js 文件中,我有这个 ajax 调用:
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
}
});
$.ajax({
url: 'api/postStream',
type: 'post',
data: { imgData: imgData },
success:function(data) {
console.log('success');
}
});
Run Code Online (Sandbox Code Playgroud)
我的 Api 路由如下所示:
Route::group(['middleware' => 'auth:api'], function()
{
Route::post('postStream', ['as' => 'image', 'uses' => 'ApiController@postStream']);
});
Run Code Online (Sandbox Code Playgroud)
还有我的控制器:
public function postStream(Request $request)
{
$imgData = $request->imgData;
...
}
Run Code Online (Sandbox Code Playgroud)
但我在我的 chrome 开发控制台中收到此错误:
POST http://localhost/app/public/api/postStream 401 (Unauthorized)
Run Code Online (Sandbox Code Playgroud)
在网络工具中:
{error: "Unauthenticated."}
error
:
"Unauthenticated."
Run Code Online (Sandbox Code Playgroud)
我想我有点没有经过身份验证,但我不知道如何以这种方式实现。
javascript ×5
laravel ×4
php ×4
ajax ×2
api ×2
html ×2
jquery ×2
android ×1
background ×1
canvas ×1
command ×1
command-line ×1
css ×1
exists ×1
html5-canvas ×1
image ×1
imagemagick ×1
imagick ×1
laravel-5.3 ×1
laravel-5.4 ×1
opacity ×1
postman ×1
protocols ×1
shell ×1
shell-exec ×1
variables ×1
z-axis ×1