2012-04-05 56 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) { 

被追加?到你的网址,当它应该是一个&因为,在问题的情况下,你的网址已经有一个?