小编Sta*_*boy的帖子

Angular 2 Http.Post没有发送请求

尝试使用一些数据对我的服务器进行简单的POST,并返回一些JSON数据.(目前,它通过电话运行,但我在网络选项卡上看不到它实际上试图制作它?)

我的服务(api.service.ts)

import { Injectable }    from '@angular/core';
import { Headers, Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Rx';

// Import RxJs required methods
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';

@Injectable()
export class ApiService {

	private headers = new Headers({'Content-Type': 'application/json'});
  	private myUrl = 'https://www.mywebsite.com';  // URL to web api
  	private payLoad = {"thingy1":"Value1", "thingy2":"value2"};

  	constructor(private http:Http) { }

  	getData () {
        this.http.post(this.myUrl, JSON.stringify(this.payLoad), this.headers)
        	.map((res:Response) => res.json())
            .catch((error:any) => Observable.throw(error.json().error || 'Server error'));
    } 

}
Run Code Online (Sandbox Code Playgroud)

然后我只是在头组件中运行getData方法来触发它.(header.component.ts)

import { Component, OnInit } …
Run Code Online (Sandbox Code Playgroud)

javascript typescript ecmascript-6 angular

9
推荐指数
1
解决办法
4822
查看次数

简单的Ajax请求,循环遍历React.js中的数据

新的反应,而不是100%我应该如何处理这个相对简单的问题.我目前正在寻找从Reddit收集一些图像,将这些图像推回到'pImage'状态.

然后将那些所述图像显示在'content'div中.通常情况下,我会用for循环来解决这个问题,但有一种特殊的方法我应该用反应处理它吗?

componentDidMount: function() {
      var self = this;
      $.get(this.props.source, function(result) {
        var collection = result.data.children;
        if (this.isMounted()) {
          this.setState({
            //Should I put a for loop in here? Or something else?
            pImage: collection.data.thumbnail
          });
        }
      }.bind(this));
    }
Run Code Online (Sandbox Code Playgroud)

小提琴显示我当前的状态:https://jsfiddle.net/69z2wepo/2327/

javascript reactjs

7
推荐指数
1
解决办法
1万
查看次数

Jquery,$(this).next问题

试图在这里截断一些代码并遇到问题:

<script type="text/javascript">
  $(function() {
  $('#a1').click(function() {
    $(this).next('#desCopy').appendTo('#description');
    $(this).next('#imgPlace').appendTo('#IMGbox');
    return false;
  });
});
</script>

    <!--Content-->


    <div id="content" style="background:#000; width:989px;">

        <div style="float:left; left:18px; margin:0; width:337px; position:relative; padding:15px 0 0 0; color:#FFF;">


            <div id="description">

            </div>

        </div>

        <div id="IMGbox" style="float:left; position:relative; display:block; background:#F00; width:652px; height:258px; background:#0FF; overflow:hidden;">



        </div>

        <div style="float:right; background:#CCC; height:25px; width:652px;">

            <ul>

                <li><a id="a1" href="#">Slide 1</a>
                    <ul style="display:none;">
                        <li><span id="desCopy">Test description, Test description</span></li>
                        <li><img src="images/test.jpg" id="imgPlace"></li>
                    </ul>
                </li>

                <li><a id="a1" href="#">Slide 2</a>
                    <ul style="display:none;">
                        <li><span id="desCopy">2222, 22222</span></li>
                        <li><img src="images/test2.jpg" id="imgPlace"></li>
                    </ul> …
Run Code Online (Sandbox Code Playgroud)

jquery

2
推荐指数
1
解决办法
6856
查看次数

Jquery到Mootools

试图让这个(简单!)jQuery表达式在Mootools中运行

jQuery的:

    checkCurrentModule = function(){
        jQuery(".module ul li.current").prepend("<b class='arrow'></b>");
    };
Run Code Online (Sandbox Code Playgroud)

这是我在Mootools的尝试

    var checkCurrentModule = function(){
            var injectModuleli = $$("li.current");
            var currentArrow = new Element("<b class='arrow'></b>");
            currentArrow.inject(injectModuleli);
        };     
Run Code Online (Sandbox Code Playgroud)

javascript jquery mootools

2
推荐指数
1
解决办法
671
查看次数

Jquery,没有改变css的最高价值

所以我遇到的问题是用像素(px)扩展名改变我的#scroll top:value.

#container {
 height:100px;
 overflow:hidden;
}

#scroll {
 position:relative;
 top:0px;
}
<div id="container">

<p>
 <a id="up">Up</a>
</p>

<div id="scroll">up down blah</div>

</div>

$(function(){
  $("#up").hover(function(){
    var topVal = $( 0 + "px");
    $("#scroll").css("top", topVal-10 + "px");
  });
Run Code Online (Sandbox Code Playgroud)

html css jquery

1
推荐指数
1
解决办法
6503
查看次数

Mootools类,json处理/函数未定义

如果你在这里看到一些你认为可以改进的东西,请告诉我!

问题:我正在尝试通过mootools类完成处理一些Json数据的基本结构.我目前遇到的是当我调用'this.processObj'时我收到'processObj未定义'

码:

this.runSomeJson= new Class({

    Implements: [Options, Events],

    options: {
        contentInfo: false,
    },
    initialize: function(element, options) {
        this.element = document.id(element);
        if (!this.element) return;
        this.setOptions(options);
        this.setBasicInfo();
    },
    setBasicInfo: function () {
        var callThis = 'somegenericurl';
        this.getObj(callThis);
    },
    getObj: function (callThis) {
        var jsonReq = new Request.JSON({
          method: 'get',
          url: callThis,
          onRequest: function () {
            console.log('Loading: ' + callThis);
          },
          onComplete: function(thisObj){
            //console.log(thisObj);
            this.processObj(thisObj);
          }
        }).send();  
    },
    processObj: function (thisObj) {
        console.log('in process..');
    },
});
Run Code Online (Sandbox Code Playgroud)

javascript mootools json

0
推荐指数
1
解决办法
321
查看次数

标签 统计

javascript ×4

jquery ×3

mootools ×2

angular ×1

css ×1

ecmascript-6 ×1

html ×1

json ×1

reactjs ×1

typescript ×1