npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jquery.redirect

v1.2.0

Published

jQuery Redirect Plugin

Downloads

4,458

Readme

jQuery.redirect

A simple HTTP POST and GET Redirection Plugin for jQuery

  • Easy to use
  • GET and POST requests
  • Compatible with jQuery, jQlite and Zepto.js
  • Supports nested objects and arrays

How does it work?

The function jQuery.redirect will create a form and populate it with the data (it supports nested values).

Installation

Using Bower

bower install jquery.redirect

Using NPM

npm install --save jquery.redirect

Using Yarn

yarn add jquery.redirect

Manual Installation

Just download jquery.redirect.js and include it in your html after jquery.js

<html>
<head>
    <!-- other headers -->
    <script src="jquery-XXX.js"></script>
    <script src="jquery.redirect.js"></script>
</head>
<body>
    <!-- your content -->
</body>
</html>

CDN

If you prefer, you can use RawGit CDN hosted version

Usage

/**
* jQuery Redirect
* @param {string} url - Url of the redirection
* @param {Object} values - (optional) An object with the data to send. If not present it will look for values as QueryString in the target url.
* @param {string} method - (optional) The HTTP verb can be GET or POST (defaults to POST)
* @param {string} target - (optional) The target of the form. If you set "_blank" will open the url in a new window.
* @param {boolean} traditional - (optional) This provides the same function as jquery's ajax function. The brackets are omitted on the field name if its an array.  This allows arrays to work with MVC.net among others.
* @param {boolean} redirectTop - (optional) If its called from a iframe, force to navigate the top window.
* @param {boolean} shouldKeepBlankFields - (optional) If shouldKeepBlankFields is false, blank fields will be removed.
*/
$.redirect(url, [values, [method, [target, [traditional, [redirectTop, [shouldKeepBlankFields]]]]]])

/**
* jQuery Redirect
* @param {string} opts - Options object
* @param {string} opts.url - Url of the redirection
* @param {Object} opts.values - (optional) An object with the data to send. If not present will look for values as QueryString in the target url.
* @param {string} opts.method - (optional) The HTTP verb can be GET or POST (defaults to POST)
* @param {string} opts.target - (optional) The target of the form. "_blank" will open the url in a new window.
* @param {boolean} opts.traditional - (optional) This provides the same function as jquery's ajax function. The brackets are omitted on the field name if its an array.  This allows arrays to work with MVC.net among others.
* @param {boolean} opts.redirectTop - (optional) If its called from a iframe, force to navigate the top window.
* @param {boolean} opts.shouldKeepBlankFields - (optional) If shouldKeepBlankFields is false, blank fields will be removed.
*/
$.redirect(opts)

Example of use with Object

<html>
<head>
    <!-- other headers -->
    <script src="jquery-XXX.js"></script>
    <script src="jquery.redirect.js"></script>
    <script>
     jQuery(function($){
     //OnClick testButton do a POST to a login.php with user and pasword
      $("#testButton").click(function(){
       $.redirect("/login.php", {user: "johnDoe", password: "12345"}, "POST", "_blank");
      });
     });
    </script>
</head>
<body>
   <button id="testButton">Test Redirect</button>
</body>
</html>

Example of use with links

<html>
<head>
    <!-- other headers -->
    <script src="jquery-XXX.js"></script>
    <script src="jquery.redirect.js"></script>
    <script>
     jQuery(function($){
     //OnClick link do a POST to a login.php with query string
     // data (user and pasword in this case)
      $("body").on("click",".post-redirect", function(){
        $.redirect($(this).attr("href"));
      });
     });
    </script>
</head>
<body>
   <a href="/login.php?user=johnDoe&password=12345" class="post-redirect">Test redirect</a>
</body>
</html>

Running Tests with Yarn

yarn install
yarn test