2016年2月29日月曜日

PHPサーバーに、javascript ajax でJSON を送信する際に、 「&」「"」のエンコードのメモ

PHPサーバーに、javascript ajax でJSON を送信する際に、
 「&」「"」のエンコードのメモ

他の方法があれば、教えてください。


Javascript 側送信
1.   事前に文字列を置き換

     文字列を書き換えしない場合、送信することが
     できますが PHPサーバー側「&」 リンクが切、「"」は
     文字列エラーになります。
   
     var c = '樂凡&祁隆 - 愛"你一"生';
     JSON.stringify({send:c});     << NG
     c.replace(/&/g,"%26");
     c.replace(/"/g,"%22");

2   encodeURI() でエンコードします。
     c=encodeURI(c);

2.  JSON.stringify で送信します。
   
     JSON.stringify({send:c});





PHPサーバー側受け取る

1.  json_decode で
    JSON エンコードされた文字列を受け取り、
    それを PHP の変数に変換します。

2.  urldecode で
    URL エンコードされた文字列をデコードする。

    $temp = json_decode($p);
    $a = urldecode($temp->send);

 


















2016年2月28日日曜日

JSON.parse ダブルクォーテーションを 解析するとエラーになります。

JSON.parse ダブルクォーテーションを 解析するとエラーになります。
eval 関数以外の方法はないでしょうか?



{"a":"\u6797\u590f\u8587 Rosina Lam \ufe63 \u5f88\u60f3\u8a0e\u53ad\u4f60 I Wish I Could Hate You (TVB\u5287\u96c6\"\u55ae\u6200\u96d9\u57ce\"\u4e3b\u984c\u66f2) (OFFICIAL AUDIO)","b":"\u6a02\u51e1&\u7941\u9686 - \u611b\"\u4f60\u4e00\"\u751f"}













2016年2月26日金曜日

Notepad++ 最後の行を画面の最上に表示する方法

Notepad++  最後の行を画面の最上に表示する方法

Plugin の 「Notepad#」を追加します。


















2016年2月12日金曜日

イメージファイルのオリジナルサイズを確認する

イメージファイルのオリジナルサイズを確認する

.naturalHeight
.naturalWidth 

function item_cards_event(){
        var x = document.getElementsByClassName('item_cards');
        for(var i = 0; i<x.length; i++){
               x[i].addEventListener("mouseover",function(e){
                        this.style.boxShadow = "3px 3px 14px";
                    console.log(this.firstElementChild.nextElementSibling.firstElementChild.naturalWidth + 'x' + this.firstElementChild.nextElementSibling.firstElementChild.naturalHeight);
                },false);

                x[i].addEventListener("mouseout",function(e){
                         this.style.boxShadow = "1px 1px 1px";
                },false);
        }
}

item_cards_event();





function item_cards_event(){
        var x = document.getElementsByClassName('thumbnail_a');
        for(var i = 0; i<x.length; i++){
               x[i].addEventListener("mouseover",function(e){
                        this.style.boxShadow = "3px 3px 14px";
                        console.log(this.firstElementChild.alt);
                        console.log(this.firstElementChild.naturalWidth + 'x' + this.firstElementChild.naturalHeight);
                },false);
                         x[i].addEventListener("mouseout",function(e){
                         this.style.boxShadow = "1px 1px 1px";
                },false);
        }
}

item_cards_event();






2016年2月2日火曜日

location プロパティ

location プロパティ


location.href
"http://www.asus.com/Motherboards/Z170-PRO/?SearchKey=Z170/"

location.origin
"http://www.asus.com"

location.protocol
"http:"

location.host
"www.asus.com"

location.hostname
"www.asus.com"

location.pathname
"/Motherboards/Z170-PRO/"

location.search
"?SearchKey=Z170/"