RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-247816

Артём PeGaS's questions

Martin Hope
Артём PeGaS
Asked: 2020-09-23 04:12:47 +0000 UTC

如何发送带有数据的发布请求?

  • 0

我将图像发送到服务 api:

let img = fs.readFileSync('public/img/logo.jpg');


var options = {
    body: img,
    headers: {
        Authorization: `Basic ${new Buffer.from(`api:<my API>`).toString('base64')}`,
    },
    method: 'POST',
    hostname: 'api.tinify.com',
    path: '/shrink'
  };

https.request(options, function(res,req){
    var data = '';
    res.on('data', function(chunk){
        data += chunk;
    });
    res.on('end', function(e){
        console.log(data);
    });
}).end();

控制台说:{"error":"InputMissing","message":"输入文件为空"}

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Артём PeGaS
Asked: 2020-06-06 14:06:22 +0000 UTC

如何从服务器获取 JSON 数据?

  • 0

我有一个data.json数据文件。我通过以下方式在 JS 中请求数据XMLHttpRequest:

    let request = new XMLHttpRequest();
    request.open('GET', 'data.json');

    request.send();

request.onreadystatechange = () => {
    if( request.readyState === 4 ) {
        alert(request.responseText);
    }
};

如何从中获取数据data.json?

需要什么 php 脚本将数据从文件返回到data.json客户端?

php
  • 1 个回答
  • 10 Views
Martin Hope
Артём PeGaS
Asked: 2020-04-17 15:21:39 +0000 UTC

如何从谷歌地图路线获取航点?

  • 1

谷歌地图中有一条从A点到B点的路线。是否可以从这条路线每100米得到点的坐标?

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Артём PeGaS
Asked: 2020-04-16 17:14:08 +0000 UTC

为什么元素会在网格容器中跳转?

  • 1

为什么元素没有缩小?他们会在达到最小宽度之前立即跳跃吗? https://jsfiddle.net/baar6uoj/

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 200px));
  grid-gap: 20px;
}

.grid div {
  background-color: #28314E;
  border: 1px solid #212941;
  border-radius: 5px;
  padding: 8px 15px;
  color: #ffffff;
  font-size: 18px;
  font-family: roboto;
}

.grid div:nth-child(odd) {
  background-color: #475477;
}
<div class="grid">
  <div>item-1</div>
  <div>item-2</div>
  <div>item-3</div>
  <div>item-4</div>
</div>

html
  • 1 个回答
  • 10 Views
Martin Hope
Артём PeGaS
Asked: 2020-03-23 21:58:12 +0000 UTC

是否可以在谷歌地图中设置 let route 的样式?

  • 0

使从点到点的道路可以涂成任意颜色

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Артём PeGaS
Asked: 2020-02-17 05:05:10 +0000 UTC

如何获取 youtube API 的客户端 ID

  • 0

我在 console.cloud.google.com 上注册了 我可以用箭头来告诉我在哪里点击进入/去哪里 нажать сюда -> потом сюда -> откроется это -> и т.д.?只是设计发生了变化,所有视频都没有在旧设计上显示。我已经受苦了很长时间,无法获得 Youtube API 的 CLIENT ID。谢谢!

youtube-api
  • 1 个回答
  • 10 Views
Martin Hope
Артём PeGaS
Asked: 2020-12-31 03:34:25 +0000 UTC

jQuery ajax 中没有“parsererror”错误

  • 1

我的目标是在回调函数中查看“parsererror”状态。“parsererror”表示数据已接收但形成错误。所以我故意在data.json文件中犯了一个错误——我写了垃圾。例如:{fgg-8f6+8} 并且“parsererror”不输出。

function fun(a, s, c) {
        console.log(s); // нету "parsererror"
    }

    $.getJSON('data.json', fun);

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Артём PeGaS
Asked: 2020-12-20 00:02:25 +0000 UTC

帮我理解程序的步骤

  • 1

getJSONP("ph.php", call); 函数被调用了 2 次。结果,创建了 2 个脚本元素 - 在 getJSONP.eee 函数中执行。getJSONP.eee 函数被覆盖。这意味着两个脚本元素将执行相同的 getJSONP.eee 函数 - 其中脚本变量是最后一个脚本标记。

问题:为什么在第二次调用警报(脚本);表示该元素存在,尽管它在第一次调用时被删除。错误是 TypeError: script.parentNode is null

function call(a) {
  alert(a);
}
function getJSONP(url, callback) {
        url += "?jsonp=getJSONP.eee";

    var script = document.createElement("script");
    alert(7);
    getJSONP.eee = function(response) {
        script.title="two"; // Для отслеживания тег взаимодейстия
        alert(document.getElementsByTagName("script").length); // Сколько всего тегов
		  callback(response); // Результат
		  alert(script); // Проверить на наличие тега
		  script.parentNode.removeChild(script); // Удалить тег
		  alert(script); // Проверить на наличие тега. Почему есть?
    };

   
    script.src = url;
    document.body.appendChild(script);
    if(t==1) script.title="one"; // Для отслеживания тег взаимодейстия
}
var t = 1;
getJSONP( "ph.php", call);
getJSONP( "ph.php", call); // При этом getJSONP.eee - перезаписывается

<?php

$seq = array("foo", "bar", "baz", "blong");
$json = json_encode($seq);

echo $_GET['jsonp'].'('.$json.')';

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Артём PeGaS
Asked: 2020-12-19 01:57:34 +0000 UTC

JSONP服务器没有返回数据

  • 1

帮助从服务器获得响应。有一个使用脚本标签以 JSONP 格式执行请求的功能

function call(a) {
  alert(a);
}
function getJSONP(url, callback) {
    // Create a unique callback name just for this request
    var cbnum = "cb" + getJSONP.counter++; // Increment counter each time
    var cbname = "getJSONP." + cbnum;      // As a property of this function
    if (url.indexOf("?") === -1)   // URL doesn't already have a query section
        url += "?jsonp=" + cbname; // add parameter as the query section
    else                           // Otherwise, 
        url += "&jsonp=" + cbname; // add it as a new parameter.

   
    var script = document.createElement("script");
    getJSONP[cbnum] = function(response) {
        try {
            callback(response); // Handle the response data
        }
        finally {               // Even if callback or response threw an error
            delete getJSONP[cbnum];                // Delete this function
            script.parentNode.removeChild(script); // Remove script
        }
    };

   
    script.src = url;                  // Set script url
    document.body.appendChild(script); // Add it to the document
}

getJSONP.counter = 0;  // A counter we use to create unique callback names


getJSONP( "ph.php", call);
getJSONP( "http://my/ph.php", call);

这是 ph.php 本身,数据应该来自哪里作为响应

<?php
	$seq = array("foo", "bar", "baz", "blong");
	$json = json_encode($seq);
	echo $json

但是浏览器显示错误: SyntaxError: expected expression, got '<'[More] ph.php:1 SyntaxError: expected expression, got '<'[更多]

php
  • 1 个回答
  • 10 Views
Martin Hope
Артём PeGaS
Asked: 2020-11-03 18:02:41 +0000 UTC

使用 toString 方法将数字转换为字符串

  • 6

为什么没有将数字对象转换为字符串?毕竟,我在原型中定义了方法toString:

Number.prototype.toString = function() {
  return "wrwer";
}
var a = 5;
console.log(a + '');

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Артём PeGaS
Asked: 2020-09-25 03:33:27 +0000 UTC

如何抽象脚本?[关闭]

  • -1
关闭。这个问题需要澄清或补充细节。目前不接受回复。

你想改进这个问题吗?通过编辑此帖子添加更多详细信息并澄清问题。

4年前关闭。

改进问题

如何将此脚本放入单独的函数中?并且能够多次调用它

function loadScript() {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src = "http://maps.googleapis.com/maps/api/js?sensor=true&callback=initializeMap";
  document.body.appendChild(script);
}
if (window.addEventListener) window.addEventListener("load", loadScript, false);
else if (window.attachEvent) window.attachEvent("onload", loadScript);

function initializeMap() {
  var myLatlng = new google.maps.LatLng(56.7342973, 37.1636543);
  var uluru = {
    lat: 56.7332973,
    lng: 37.1759543
  };
  var myOptions = {
    zoom: 15,
    scrollwheel: false,
    center: uluru,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    mapTypeControlOptions: {
      position: google.maps.ControlPosition.BOTTOM_LEFT
    }
  };
  var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

  var markerImage = new google.maps.MarkerImage(
    'images/pointMaps.png',
    new google.maps.Size(42, 61)
  );
  var markerImageHover = new google.maps.MarkerImage(
    'images/pointMaps.png',
    new google.maps.Size(42, 61)
  );

  var marker = new google.maps.Marker({
    icon: markerImage,
    position: myLatlng,
    map: map,
    title: "Hello World!"
  });

  var content = document.createElement('div');
  content.innerHTML = "<strong>Hello world</strong> + JS ^_^";
  var infowindow = new google.maps.InfoWindow({
    content: content
  });

  google.maps.event.addListener(marker, 'click', function() {
    infowindow.open(map, marker);
  });

  google.maps.event.addListener(marker, 'mouseover', function() {
    marker.setIcon(markerImageHover);
  });

  google.maps.event.addListener(marker, 'mouseout', function() {
    marker.setIcon(markerImage);
  });
}

javascript
  • 2 个回答
  • 10 Views
Martin Hope
Артём PeGaS
Asked: 2020-09-23 03:19:03 +0000 UTC

为什么轮播事件不触发?

  • 0

为什么 $('#wrapper') 上的“点击”事件不触发?

https://jsfiddle.net/hhnq8a26/16/

$('.owl-carousel').owlCarousel({
  loop: true,
  margin: 10,
  nav: true,
  responsive: {
    0: {
      items: 1
    },
    600: {
      items: 1
    },
    1000: {
      items: 1
    }
  }
});
$('#wrapper').click(function(){
alert(44);
})
#element1,
#element2 {
  width: 100px;
  height: 100px;
  background: #000;
}
#wrapper{
  position: relative;
  z-index: 99999;
  background: gray;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.2.1/owl.carousel.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="owl-carousel carousel1">
  <div class="item">

    <div id="wrapper">
      <div id="element1"></div>
      <div id="element2"></div>
    </div>

  </div>
  <div class="item">
    <h4>13</h4></div>
</div>

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Артём PeGaS
Asked: 2020-09-10 22:52:09 +0000 UTC

如何设置应用事件的可能性之间的间隔?

  • 2

如何设置应用事件的可能性之间的间隔?比如这样点击一个div后,下一次点击只能在3秒后重复 https://jsfiddle.net/nnj4m728/1/

$('div').click(function(){
	alert(665);
});
div {
 height: 200px;
 background: #000;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div></div>

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Артём PeGaS
Asked: 2020-09-09 00:03:06 +0000 UTC

如何单击滚动按钮并滚动 2 个轮播?

  • 0

这里有 2 个轮播:https ://jsfiddle.net/hhnq8a26/1/如何制作,以便当您单击其中一个的上一个按钮(红色背景)时,两个轮播同时滚动。两个轮播可以位于相距很远的不同街区。单击分页按钮并滚动 2 个轮播

		$(document).ready(function() {

$('.owl-carousel').owlCarousel({
    loop:true,
    margin:10,
    nav:true,
    responsive:{
        0:{
            items:1
        },
        600:{
            items:3
        },
        1000:{
            items:5
        }
    }
})
		});
.q1 .owl-prev {
  background: red;
}
<div class="owl-carousel q1">
    <div class="item"><h4>1</h4></div>
    <div class="item"><h4>2</h4></div>
    <div class="item"><h4>3</h4></div>
    <div class="item"><h4>4</h4></div>
    <div class="item"><h4>5</h4></div>
    <div class="item"><h4>6</h4></div>
    <div class="item"><h4>7</h4></div>
    <div class="item"><h4>8</h4></div>
    <div class="item"><h4>9</h4></div>
    <div class="item"><h4>10</h4></div>
    <div class="item"><h4>11</h4></div>
    <div class="item"><h4>12</h4></div>
</div>
<div class="owl-carousel">
    <div class="item"><h4>1</h4></div>
    <div class="item"><h4>2</h4></div>
    <div class="item"><h4>3</h4></div>
    <div class="item"><h4>4</h4></div>
    <div class="item"><h4>5</h4></div>
    <div class="item"><h4>6</h4></div>
    <div class="item"><h4>7</h4></div>
    <div class="item"><h4>8</h4></div>
    <div class="item"><h4>9</h4></div>
    <div class="item"><h4>10</h4></div>
    <div class="item"><h4>11</h4></div>
    <div class="item"><h4>12</h4></div>
</div>

javascript
  • 2 个回答
  • 10 Views
Martin Hope
Артём PeGaS
Asked: 2020-09-07 18:30:46 +0000 UTC

为什么猫头鹰旋转木马无法连接?

  • 1

为什么猫头鹰旋转木马不工作?

$(document).ready(function() {

  $('.owl-carousel').owlCarousel({
    loop: true,
    margin: 10,
    nav: true,
    responsive: {
      0: {
        items: 1
      },
      600: {
        items: 3
      },
      1000: {
        items: 5
      }
    }
  })
  
});
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.carousel.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.2.1/assets/owl.theme.default.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.2.1/owl.carousel.min.js"></script>

<div class="owl-carousel">
  <div class="item"><h4>1</h4></div>
  <div class="item"><h4>2</h4></div>
  <div class="item"><h4>3</h4></div>
  <div class="item"><h4>4</h4></div>
  <div class="item"><h4>5</h4></div>
  <div class="item"><h4>6</h4></div>
  <div class="item"><h4>7</h4></div>
  <div class="item"><h4>8</h4></div>
  <div class="item"><h4>9</h4></div>
  <div class="item"><h4>10</h4></div>
  <div class="item"><h4>11</h4></div>
  <div class="item"><h4>12</h4></div>
</div>

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Артём PeGaS
Asked: 2020-06-21 15:13:47 +0000 UTC

将字符串传递给函数[重复]

  • 0
这个问题已经在这里得到回答:
如何在 JS 中的点之前插入(转义)变量 (1 个答案)
解析值“方向”时出错。丢失公告 (2 个回答)
5 年前关闭。

您需要将字符串 'ema' 传递给函数,以便 mai 参数使用传递的字符串。如果您直接使用“ema”而不是 mai,那么一切正常。

function ValideForm(mai){
    $('form').validate({
        rules:{
            mai:{required:true, email:true}
        },
        messages:{
            mai:{required:"Обязателен для заполнения", 							   						 email:"Некорректно"}
        }    
    });
}

ValideForm('ema');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.16.0/jquery.validate.min.js"></script>

<form action="">
 <label for="">Ваша почта:</label>
<input type="text" class="t4 email" name="ema">
</form>

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Артём PeGaS
Asked: 2020-06-15 19:38:18 +0000 UTC

如何按字母顺序对链接进行排序

  • 2

有了这个,我只对文本进行了排序,但链接保留在原来的位置。排序后如何让链接文字与链接地址匹配?

var x = $('ul li').length;
var mas = [];
var mas2 = [];
$('ul li').each(function( index ) {
  mas[index] = $(this).text();
 mas2[index] = $(this).find('a').attr('href');
});
mas.sort();
$( 'ul li' ).each(function( index ) {
 $(this).find('a').text( mas[index]);
  $(this).find('a').attr( 'href', mas2[index] );
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul>
  <li><a href="h1">7</a></li>
  <li><a href="h2">6</a></li>
  <li><a href="h3">5</a></li>
  <li><a href="h4">4</a></li>
  <li><a href="h5">3</a></li>
  <li><a href="h6">2</a></li>
  <li><a href="h7">1</a></li>
</ul>

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Артём PeGaS
Asked: 2020-05-13 18:54:26 +0000 UTC

为什么移动适配不起作用?[关闭]

  • 1
关闭 这个问题是题外话。目前不接受回复。

寻求调试帮助的问题(“为什么这段代码不起作用? ”)应该包括所需的行为、具体问题或错误,以及在问题中正确重现它的最少代码。没有明确描述问题的问题对其他访问者来说是无用的。请参阅如何创建最小、独立且可重现的示例。

5 年前关闭。

改进问题

这是网站http://centeredinstvo.ru/如果您通过减小浏览器的宽度来减小计算机屏幕,则可以进行改编。但是,如果您转到开发人员工具 f12 切换设备工具栏并减小那里的宽度,则适配不起作用。为什么?

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Артём PeGaS
Asked: 2020-05-06 21:03:20 +0000 UTC

滚动到块时,应用样式在条件中写什么?

  • 0

在条件中写什么,以便当浏览器的顶部(边框)到达具有块类的块时,应用样式?

$(window).scroll(function(){
if ( //Если "верхушка" окна коснулась блок с классом .block){
$('.block').addClass("fixed");
}
});

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Артём PeGaS
Asked: 2020-05-03 05:19:12 +0000 UTC

Image on top of select 如何让点击图片就像点击选择一样?

  • 1

单击图像时如何使其弹出列表?

div{
  position: relative;
  width:216px;
  height: 30px;
  margin-top: 10px;
}
select{
  width:100%;
  height: 100%;
  padding-left: 50px;
  background: linear-gradient(to left, #007A31 25px, white 25px, white 100%);
  
}

div img{
	position: absolute;
	right: 4px;
	top: 7px;
}
<div>
<select>
  <option>Пункт 1</option>
  <option>Пункт 2</option>
</select>
<img src="css/profi-overalls-catalog.png" alt="">
</div>

html
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5