Last active
October 12, 2015 00:02
-
-
Save s-hiroshi/98eeaa7c3d00c7f72c9b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* POSTパラメーター取得 | |
* | |
* POSTメソッドのパラメーターをJSON形式で返します。 | |
* | |
* @method getData | |
* @public | |
* | |
* @param {Array} ids コントロールのid配列です。 | |
* @return {Mixed(JSON|Boolean)} POSTパラメーターをJSON形式で返します。 | |
* 引数で渡されたidに対応する要素が1つもないときはfalseを返します。 | |
*/ | |
function getData( ids ) { | |
var data = {}; | |
if (!arguments.length > 0) { | |
return false; | |
} | |
if ( !ids instanceof Array ) { | |
return false; | |
} | |
$.map( ids, function ( id ) { | |
if ( $( "#" + id ).length > 0 ) { | |
data[id] = $( "#" + id ).val(); | |
} | |
} ); | |
if ( $.isEmptyObject( data ) ) { | |
return false; | |
} | |
return data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment