I've already tried to search the web but I always get to some point from which I don't know how to get further.
I have a Visual web part which needs to load data from external sources (different domain). The sources are
.aspx pages returning
json and I need to load these data asynchronously.
1) I've tried to use the code below, but it throws an exception:
Page.RegisterAsyncTask(new PageAsyncTask(LoadData)); Page.ExecuteRegisteredAsyncTasks()
This operation requires the page to be asynchronous (the Async attribute must be set to true). at System.Web.UI.Page.RegisterAsyncTask(PageAsyncTask task)
and I'm not able to figure out how to set this attribute of the
Page directive from the webpart. Moreover in some articles and blogs I found was written that SP doesn't support it, so I left this idea. But is it possible or not? If yes, how do I set it up?
2) I tried to use jQuery ajax, but it fails and returns no error. I think that the problem can be caused by a "cross domain" call. I've found there is SPRequestExecutor, but I'm not able to find some useful info on how to use it.
What is the best approach (with some examples please)?
I bet that many SP developers need it, so there must be something.
I prefer the js solution if you could direct me to some relevant information.