Coder Social home page Coder Social logo

packages's Introduction

Packages

自己封装的js包

window.ajax=(function () {return {...需要返回的方法}})()

区别于window.ajax={},这个里面的所有属性,方法都暴露出去了,然而使用闭包的模式,可以控制暴露出去的内容.更加合理

ajax,example

属性:
url: 配置全局地址,用于单页应用.多页进入源码配置
方法:

/**
   * get
   * @param url
   * @param data (可选)
   * @param callback 返回对象类型
   */
ajax.get('/',{id:1,name:'tom'},function(res) {
  console.log(res)
})
/**
   * post
   * @param url.
   * @param data 有两种类型,一是对象,二是表单document.forms[0],表单可以实现文件上传
   * @param callback 返回对象类型
   */
ajax.post('/',{id:1,name:'tom'},function(res) {
  console.log(res)
})
/**
   * jsonp
   * @param url
   * @param callback 返回对象类型
   */
ajax.jsonp('/', function(res) {
  console.log(res)
})

packages's People

Contributors

740470290 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.