getting jsonp to work in asp.net api

106 Views Asked by At

having issues getting my jsonp to work with my client backbone script,pagenator keep gettgin invalid key error having looked around people say its to to do with my service not return jsonp.

For example SyntaxError: invalid label, i've written a mvc4 web api service this is what it returns does it look right and also is there anything i need to add to my api to support jsonp ?

   {
      "odata.metadata":"http://test.test.uk/api/odata/$metadata#lnews","value":[
        {
          "ID":1,"title":"This is a test news artical","mainContent":"<p>\r\n\tthis is a test article</p>\r\n","featured":1,"visiblehomepage":1,"thedatetime":"2013-08-05T10:36:05.98","expireon":"2013-08-15T00:00:00","category":17,"embargo":null,"embargotime":"PT0S","embargodate":null,"customthumbnail":null,"news_layout":3,"LNBE":0,"LNBN":0,"LNBS":0,"LNBW":0,"LNWV":0,"LNWS":1,"LNDY":0,"LNSW":0,"LNSH":0,"LNCV":0
        },{
          "ID":2,"title":"This is a test article","mainContent":"<p>\r\n\twelcome to the best site in the world</p>\r\n","featured":1,"homepage":1,"thedatetime":"2013-08-05T10:42:54.763","expireon":"2013-08-22T00:00:00","category":null,"embargo":null,"embargotime":"PT0S","embargodate":null,"customthumbnail":"Water lilies.jpg","news_layout":4,"LNBE":1,"LNBN":1,"LNBS":1,"ff":1,"LNWV":1,"LNWS":1,"LNDY":1,"LNSW":1,"LNSH":1,"LNCV":1
        }
      ]
    }
1

There are 1 best solutions below

0
On

Here is a JSONP URL:

http://odata.netflix.com/v2/Catalog/Genres?$format=json&$callback=?

Here is a diagram:


CLIENT                   SERVER
------                   ------

Makes URL request        Looks up function matching this URL param ($callback)

Executes asynchonously   If found, executes function asynchonously

Returns from callback    Returns data from server side as a function, or error

References