2012-04-05 57 views
0

這個例子能正常工作(不帶參數):
JSONP sample on twitterJSONP與參數

<html><head><title>Twitter 2.0</title> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 
</head><body> 
<div id='tweet-list'></div> 
<script type="text/javascript"> 
$(document).ready(function() { 
    var url = "http://api.twitter.com/1/statuses/user_timeline/codinghorror.json"; 
    $.getJSON(url + "?callback=?", null, function(tweets) { 
     for(i in tweets) { 
      tweet = tweets[i]; 
      $("#tweet-list").append(tweet.text + "<hr />"); 
     } 
    }); 
}); 
</script> 
</body></html> 

但它不與這個網址的工作:

var url = "https://thiswaschangedforsecurity/Rest/Authenticate/Login?username=jsm&password=a&ip=1"; 

當粘貼此URL返回JSON數據網址吧:

{"SessionID":"44e6f809-3b40-43fc-b425-069e9c52cbda","SourceIP":"1","UserID":313} 

但我不能讓它工作與JSONP。對此有何想法?

+0

裏面沒有我的回答沒有解決問題了嗎? – 2012-04-10 17:05:35

回答

0

要啓用JSONP(導致跨域訪問),這應該是把web.config文件

<bindings> 
    <webHttpBinding> 
    <binding crossDomainScriptAccessEnabled="true"> 
     .... 
    </binding> 
    </webHttpBinding> 
</bindings> 
0

此行

$.getJSON(url + "?callback=?", null, function(tweets) { 

被追加?到你的網址,當它應該是一個&因爲,在問題的情況下,你的網址已經有一個?