Help us understand the problem. What is going on with this article?

jsdoでget

More than 1 year has passed since last update.

概要

jsdoで、getリクエストを受けてみた。
postは、無理。

参考にしたぺージ

https://qiita.com/Evolutor_web/items/c9b940f752883676b35d

サンプルコード

var getUrlVars = function() {
    var vars = {}; 
    var param = location.search.substring(1).split('&');
    for (var i = 0; i < param.length; i++)
    {
        var keySearch = param[i].search(/=/);
        var key = '';
        if (keySearch != -1) key = param[i].slice(0, keySearch);
        var val = param[i].slice(param[i].indexOf('=', 0) + 1);
        if (key != '') vars[key] = decodeURI(val);
    } 
    return vars; 
}
var q = getUrlVars();
alert(q['a']);
alert(q['b']);

成果物

http://jsdo.it/ohisama1/qJlnU

以上。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away