<form>
<input type='text' id='ipt_hello' />
</form>
myUrl = "http://localhost:8090/api/test?callback=JSON_CALLBACK";
$http.jsonp(myUrl).success(
function(data){
alert(data);
});
注意點(diǎn):
1.angularJS中使用$http.jsonp函數(shù)
2.指定callback和回調(diào)函數(shù)名樟遣,函數(shù)名為JSON_CALLBACK時(shí)皮壁,會(huì)調(diào)用success回調(diào)函數(shù),JSON_CALLBACK必須全為大寫础芍。
3.也可以指定其它回調(diào)函數(shù)低矮,但必須是定義在window下的全局函數(shù)。
4.url中必須加上callback5.當(dāng)callback為JSON_CALLBACK時(shí)曹仗,只會(huì)調(diào)用success榨汤,即使window中有JSON_CALLBACK函數(shù),也不會(huì)調(diào)用該函數(shù)怎茫。