Does UWP app support ajax?

2019-07-10 03:29发布

问题:

I have a windows 8 hybrid app and now I want to migrate it to UWP. I am facing two issues and I have been searching on the internet for quite a few time. I want to know if UWP support ajax function. Also my anchor tag in href is not parsing. What might be the reason.

回答1:

I want to know if UWP support ajax function

The answer is yes, you can use ajax in UWP Application. But there are a few things you need to notice when using ajax in UWP.

  1. If you are using ajax to get data from a remote server, please make sure the Internet(Client) capability is enabled in package.appmanifest. If you also want to call ajax from local server, make sure the Private Networks(Client & Server) capability is enabled.

  2. If you are using a Content Security Policy in your app. Make sure the server address of your ajax call is included after default-src or connect-src in <meta>. For details about CSP you can refer to this document.

  3. Cross-Origin should also under your concern when migrating. For enable CORS you can refer to add CORS support to server.

my anchor tag in href is not parsing. What might be the reason.

For safty reason, UWP doesn't support inline javascript. So codes like <a ng-click="jsfunc();"></a> won't work. Please add eventListener in JS files.