0

This example works fine (without parameters):
JSONP sample on twitter

<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>  

But it doesn't work with this url:

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

This url returns json data when paste on url bar:

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

But I can't make it work with JSONP. Any idea about this?

Community
  • 1
  • 1
fiberOptics
  • 6,955
  • 25
  • 70
  • 105

2 Answers2

1

To enable jsonp (causes cross-domain access), this should be put inside web.config file

<bindings>
  <webHttpBinding>
    <binding crossDomainScriptAccessEnabled="true">
      ....
    </binding>
  </webHttpBinding>
</bindings>
fiberOptics
  • 6,955
  • 25
  • 70
  • 105
0

This line

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

is appending a ? to your url when it should be adding a & since, in the problem case, your url already has a ?

Eric Bridger
  • 3,751
  • 1
  • 19
  • 34