# jsonp-pro

> ajax jsonp methods

Latest version **1.1.3** (published 2025-03-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install jsonp-pro
pnpm add jsonp-pro
yarn add jsonp-pro
bun add jsonp-pro
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2025-03-20 |
| First published | 2019-01-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 75.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | peng |
| Maintainers | pengzong |
| Keywords | ajax, jsonp |

## Links

- npm: https://www.npmjs.com/package/jsonp-pro
- Repository: https://github.com/peng/jsonp-pro
- Homepage: https://github.com/peng/jsonp-pro#readme
- Issues: https://github.com/peng/jsonp-pro/issues
- npm.io page: https://npm.io/package/jsonp-pro

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.3 (latest) — 2025-03-20
- 1.1.2 — 2024-08-28
- 1.1.1 — 2022-12-22
- 1.1.0 — 2022-12-12
- 1.0.1 — 2019-10-28
- 1.0.0 — 2019-10-28
- 0.0.3 — 2019-10-25
- 0.0.2 — 2019-10-25
- 0.0.1 — 2019-01-22

## README

# jsonp-pro

> ajax jsonp methods
<p align="center">
  <a href="https://github.com/peng/jsonp-pro"><img alt="GitHub Actions status" src="https://github.com/peng/jsonp-pro/workflows/jsonp-pro%20Package/badge.svg"></a>
</p>

[中文文档](https://github.com/peng/jsonp-pro/blob/master/READMECN.md)

## awsome jsonp methods

## It is only ajax jsonp method and is very easy to use.

## Why I create it.

Hot JavaScript Framework such as Vue and React not offer ajax method. And most popular ajax method such axios and SuperAgent not support jsonp. Other open jsonp method use not very well and jQuery is big. So I create this.

## Installing

If you want use single js file. These files is in _dist_ folder. Include `amd` `cjs` `esm` `iife` `system` `umd` .

Using npm:

```
$ npm install jsonp-pro
```

Using URL:

```
// development
<script src="dist/jsonp.iife.js"></script>
// production
<script src="dist/jsonp.iife.min.js"></script>
```

## Example

Performing a ESM.

```
import jsonp from 'jsonp-pro';

const url = '/example.action';
const options = {
  data: {
    name:'peng'
  },
  success(data) {
    console.log(data);
  },
  loaded() {
    console.log("data is loaded");
  }
}

jsonp(url,options);
```

Performing a script tag

```
<script src="jsonp.iife.js" ></script>

<script>

const url = '/getinfo.action';

const options = {
  data: {
    name:'peng'
  },
  success(data) {
    console.log(data);
  },
  loaded() {
    console.log("data is loaded");
  }
}

jsonp(url,options);

</script>
```

## jsonp-pro API

jsonp(url,options)  
`url`  
Type: `string`  
Description: url path to get data, It support url include data.

Example

```
import jsonp  from 'jsonp-pro';

const url = 'https://github.com/peng?name=peng&age=18';

const options = {
  data:{
    haspet:'yes'
  },
  success(data) {
    console.log(data);
  }
}

jsonp(url,options);
```

<center>Options</center>

|     Name     |        Type        |                                                                  Default                                                                   |                                       Description                                        |
| :----------: | :----------------: | :----------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------: |
|     data     | `{String\|Object}` | `` | This data is data to send. Object format example: `{key1: value1 , key2: value2}` . String format example `"key1=value1&key2=value2"` |
|   success    |    `{Function}`    |                                                  `` | Get data success callback function.                                                  |
|   error    |    `{Function}`    |                                                  `` | Get data error callback function.                                                  |
|    loaded    |    `{Function}`    |                                                  `` | when data loaded callback function.                                                  |
|   callback   |     `{String}`     |                                                                 `callback`                                                                 |                               Custom callback key string.                                |
| callbackName |     `{String}`     |                                                       `"callback_"+(random number)`                                                        |                                  Custom callback value.                                  |
|  noCallback  |    `{Boolean}`     |                                                                  `false`                                                                   | Set no callback key and value. If true no these params. Default false have these params. |
|   charset    |     `{String}`     |                                                `` | Charset value set, Default not set any.                                                |
| timeoutTime  |     `{String}`     |                                                                  `60000`                                                                   |                     Timeout time number set. Unit ms. Default 60000.                     |
|   timeout    |    `{Function}`    | `` | Timeout callback. When timeout, run this function. When you only set `timeoutTime` and not set `timeout`. Timeout methods is invalid. |

<!-- ## Status -->

<!-- [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) -->

## Author

Released under the [MIT](./LICENSE) License.<br>
Authored and maintained by peng.

> [github.com/peng](https://github.com/peng) · GitHub [@peng](https://github.com/peng)

## License

MIT &copy; peng

<!-- ## ajax jsonp method -->

<!-- ## has support -->

---
_Source: https://npm.io/package/jsonp-pro · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
