Skip to content

Instantly share code, notes, and snippets.

View hiro-matsuno's full-sized avatar

Hironori Matsuno hiro-matsuno

  • Japan
View GitHub Profile
$.ajax({
  url:'',//データを送る相手側のURL
type:'',//ここはpop,getを記入する。使用用途によって変わってくる。
cache: ,//キャッシュを使うかどうか(IE使う時はfalseを常に利用。trueにするとキャッシュが生きてくる。)
dataType:'',//帰ってくる値の設定。xml, script, json, jsonp,textから選択可能。俺の場合はjsonかtext
data:{'key':'value'},//送信するデータを記入する。変数利用可
success:function(mydata){
    //ここに書く項目は通信がうまく行った時の処理
   },
   error:function(){
@hiro-matsuno
hiro-matsuno / gist:3465f5c41f7642d92c6d
Last active August 29, 2015 14:04
jqueryでのblur(カーソルが外れた時の処理)
//ページの初期化
$(function(){
//カーソル外した動作
$('#ID名').blur(function{
//取得したい項目を取得
//入力値チェック(例:if 取得変数.match(/[^0-9a-zA-Z]/)この場合は大文字小文字英字・数字を確認する)
});
});
@hiro-matsuno
hiro-matsuno / gist:31729b68e02ddf48aa44
Last active August 29, 2015 14:04
localStorageの主だったコマンド
//セット
localStorage.setItem('キー値','値');
//ゲット
localStorage.getItem('キー値');
//削除
localStorage.removeItem('キー値');
//バルス(全削除)
localStorage.clear();
//セット(JSON利用するとき)
localStorage.setItem('キー値',JSON.stringify('値'));
@hiro-matsuno
hiro-matsuno / gist:5ae7e6e40e881059eb74
Last active August 29, 2015 14:04
日付の取得
// 日付取得
nowDate = new Date();
nowYear = nowDate.getFullYear();
nowMonth = nowDate.getMonth() + 1;
nowDate = nowDate.getDate();
nowYMD = nowYear + "年" + nowMonth + "月" + nowDate + "日";
@hiro-matsuno
hiro-matsuno / gist:051c27214c7c88a088bd
Last active August 29, 2015 14:04
年月日時間の取得
//日付取得
nowDate = new Date();
nowYear = nowDate.getFullYear();
nowMonth = nowDate.getMonth() + 1;
if(nowMonth >= "1" && nowMonth <= "9"){
nowMonth = "0" + nowMonth;
}
nowDate = nowDate.getDate();
if(nowDate >= "1" && nowDate <= "9"){
nowDate = "0" + nowDate;
@hiro-matsuno
hiro-matsuno / gist:0c7fb91438c140c728b8
Created July 24, 2014 00:57
jqueryでのCSS変更
$('#money').css('変えたいCSS','値');
@hiro-matsuno
hiro-matsuno / gist:c41ccf9cfdac64837a91
Last active August 29, 2015 14:04
jqueryでのTable要素の操作
//table要素の削除
$('.操作したい項目').empty();
//table要素の追加
$('.操作したい項目').eq(-1).append('追加したいTable要素');
//table要素への挿入
$('.操作したい要素 .操作したいIDまたはクラス').eq(-1).val(挿入したい変数);
@hiro-matsuno
hiro-matsuno / gist:be2344860c94f03a5484
Last active August 29, 2015 14:04
gmaps.jsを使った時の地図表示など
//これはGmaps.jsを利用した時に使用できます。
//htmlファイルにgmaps.js他以下の設定が必要です。
//Webサーバにgmaps.js我は言っている前提で書いてます。
//<script src='jquery-2.1.1.min.js'></script>
//<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
//<script src='gmaps.js'></script>
$(document).ready(function(){
//マップの表示設定
map = new GMaps({
@hiro-matsuno
hiro-matsuno / gist:23d1b8bdbc2677a6e386
Last active August 29, 2015 14:04
OpenStreetMapの地図の表示とマーカー設定
//OpenLayerを使ったOpenStreetMapの地図の表示などを行っています。
//htmlファイルに以下の設定が必要です
//<script src='jquery-2.1.1.min.js'></script>
//<script src='OpenLayers.js'></script>
var map , layer;
$(function() {
//マップ変数の設定
var map = new OpenLayers.Map("map_canvas");
@hiro-matsuno
hiro-matsuno / gist:6097c995313a651ad9f2
Last active August 29, 2015 14:04
PHPのMySQLデータベース用のエスケープ処理
//mysql_real_escape_stringはPHPとMySQLを接続するためのエスケープ処理です。
//なぜmysql_real_escape_stringとtrimを組み合わせているかというとエスケープ処理しても空白を許容してはSQLインジェクションの元だからです。
mysql_real_escape_string(trim(変数名));
//今後はこっちが主流になるようです。
mysqli_real_escape_string(データベース接続詞,trim(変数名));