Giter Site home page Giter Site logo

httpbingo's Introduction

1.为XMLHttpRequest写的httpbingo.js

阅读了underscore的源码以后,我对bjax这个库的链式调用的方法做了整体的改变

具体移步https://github.com/Rlilyyy/bjax

httpbingo.js是为了更方便地使用XMLHttpRequest而写的JS函数,调用方法如下:

$.init()
	.setTarget("GET", "http://localhost/Watermalon/index.php")
	.setAsync(true)
	.setData("")
	.success(function(data) {

		data = JSON.parse(data);

		var elem = document.getElementById("start");

		elem.style.backgroundImage = "url('" + data.img + "')";

	})
	.start();

Warning!!!

  • $.init()必须在开头调用,否则无法返回一个正确的Object
  • start()必须在最后调用,否则可能会忽略在start()之后的调用的函数设置的数据
  • setTarget(type, url)用于设置连接方法与连接url地址,默认方法为GET
  • setAsync(isAsync)(未完善)用于设置是否异步传输,默认为true
  • setData(data)用于设置传输给连接的数据
  • success(callbackFun)用于设置连接成功后的回调函数,如果如此写callbackFun(data),那么data就是获取到的数据
  • error(callbackFun)(未完善)用于设置连接出错后的回调函数

httpbingo's People

Contributors

rlilyyy avatar

Stargazers

 avatar  avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.