在jQuery1.2之後,jQuery.getJSON支援cross domain取得JSON資料
client端:
<script>
$.getJSON("http://your.url.com/jsoncallback=?",
function(data){
$.each(data.items, function(i,item){
$("<img/>").attr("src", item.media.m).appendTo("#images");
});
});
</script>
要注意的是雖然我們是傳"jsoncallback=?",jQuery會自動地把?轉換成適當地method name。 所以實際上傳給server端的內容是類似"jsoncallback=jsonp1236848595320"這樣的。
在server端:
要把JSON格式的資料用()包起來並且在最前方加上傳進來的jsoncallback的值,而不是直接傳回JSON格式的資料
<?php
$jsonp = $_GET["jsoncallback"];
echo $jsonp."(".json_format_data.")";
?>
參考資料:
jQuery.getJSON documentation
Pasting text into a terminal running Vim with ‘autoindent’ or ’smartindent’ set can destroy the indenting of the pasted text.
How to solve this problem?
Before paste
:set paste
After paste
:set nopaste
Or we can just add this in .vimrc config file, so that we can make a toggle for this action.
set pastetoggle=<F9>
Reference:Toggle auto-indenting for code paste
- about:config in location bar.
- Find browser.contentHandlers by using filter.
- You can find something like this
『browser.contentHandlers.auto.application/vnd.mozilla.maybe.feed』
and then reset the value of this item.
- Restart Firefox!
reference: Adding feed readers to Firefox
a:link {color: #FF0000} /* unvisited link */
a:visited {color: #00FF00} /* visited link */
a:hover {color: #FF00FF} /* mouse over link */
a:active {color: #0000FF} /* selected link */
Note: a:hover MUST come after a:link and a:visited in the CSS definition in order to be effective!!
Note: a:active MUST come after a:hover in the CSS definition in order to be effective!!
We can use php as a shell script by adding the line below at the top of the php script file.
#!/usr/local/bin/php -Cq
C means do not change working directory to that of the script.
q means do not send HTTP header.
There is a reference manual 『Using PHP from the command line』 in php.net
PHP中include和require的差異在於找不到引入的檔案時,require會停止解譯php程式,include則不會。
在Oracle中找出重複的紀錄的方法
SELECT aid FROM atable GROUP BY aid HAVING COUNT(*) >1;
刪除重複的記錄
DELETE FROM atable a where a.ROWID!=(SELECT MAX(ROWID) FROM atable b WHERE a.aid=b.aid;
藉由從abc_stu資料表內抓取該學號的生日,來更新stu資料表裡每個學號的生日。
DECLARE
CURSOR cur IS
SELECT stuid FROM stu;
BEGIN
FOR rec IN cur
LOOP
UPDATE stu
SET (birth_yr,birth_mm,birth_dd)=
(SELECT birth_yr,birth_mm,birth_dd FROM abc_stu WHERE stuid=rec.stuid)
WHERE stuid=rec.stuid;
END LOOP;
END;
If data exists then update it, otherwise insert it.
In Oracle/PLSQL
BEGIN
UPDATE TABLE_NAME SET COL=’a’ WHERE ID=’foobar’;
IF sql%rowcount = 0 THEN
INSERT INTO TABLE_NAME (ID,COL) VALUES(‘foobar’,'a’);
END IF;
END;
session_test.php
<?php
session_start();
$_SESSION['IDNO']=’A1234′;
$_SESSION['DPT_COD'][0]=’1402′;
$_SESSION['DPT_COD'][1]=’B402′;
Print_r($_SESSION);
echo 『<br /><a href=』session_test2.php』>next!</a>』;
?>
The browser show:
Array ( [IDNO] => A1234 [DPT_COD] => Array ( [0] => 1402 [1] => B402 ) )
next!
session_test2.php
<?php
session_start();
echo 『Original SESSION array values:<br />』;
Print_r($_SESSION);
echo 『<br /><br />』;
echo 『New SESSION array values:<br />』;
$IDNO=’Z5678′;
$DPT_COD=’foobar’;
Print_r($_SESSION);
session_unset();
session_destroy();
?>
In machine 1
The browser show:
Original SESSION array values:
Array ( [IDNO] => A1234 [DPT_COD] => Array ( [0] => 1402 [1] => B402 ) )
New SESSION array values:
Array ( [IDNO] => Z5678 [DPT_COD] => foobar )
In machine 2
The browser show:
Original SESSION array values:
Array ( [IDNO] => A1234 [DPT_COD] => Array ( [0] => 1402 [1] => B402 ) )
New SESSION array values:
Array ( [IDNO] => A1234 [DPT_COD] => Array ( [0] => 1402 [1] => B402 ) )
I think the result in machine 2 is what it should be.
But I don’t know why macheine 1 show that diffrent result.
The answer is someone turn on register_globals in php.ini in machine 1.