2013-08-07 19 views
0

有問題讓我的jsonp與我的客戶端骨幹腳本一起工作,pagenator保留gettgin無效的關鍵錯誤 有人看過周圍的人說它與我的服務沒有返回jsonp。讓jsonp在asp.net api中工作

例如SyntaxError:無效標籤,我已經寫了一個mvc4 web api服務,這是它返回它看起來是否正確,還有什麼我需要添加到我的API來支持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 
     } 
     ] 
    } 

回答

0

這裏是一個JSONP URL:

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

下面是一個圖:

 

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 

參考