UWP应用程序是否支持Ajax? [英] Does UWP app support ajax?
问题描述
我有一个Windows 8混合应用程序,现在我想将其迁移到UWP.我面临两个问题,并且已经在互联网上搜索了很长时间了.我想知道UWP是否支持Ajax功能.另外,我在href中的锚标记无法解析.可能是什么原因.
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.
推荐答案
我想知道UWP是否支持ajax功能
I want to know if UWP support ajax function
答案是肯定的,您可以在UWP Application中使用ajax.但是,在UWP中使用Ajax时,需要注意一些事项.
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.
-
如果您正在使用ajax从远程服务器获取数据,请确保在
package.appmanifest
中启用了Internet(Client)
功能.如果您还想从本地服务器调用ajax,请确保已启用Private Networks(Client & Server)
功能.
If you are using ajax to get data from a remote server, please make sure the
Internet(Client)
capability is enabled inpackage.appmanifest
. If you also want to call ajax from local server, make sure thePrivate Networks(Client & Server)
capability is enabled.
如果您在应用程序中使用内容安全策略.确保在 <meta>
中的 default-src
或 connect-src
之后包括了您的Ajax调用的服务器地址.有关CSP的详细信息,请参阅本文档.
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.
跨源也应引起您的关注.要启用CORS,您可以参考向服务器添加CORS支持.
Cross-Origin should also under your concern when migrating. For enable CORS you can refer to add CORS support to server.
我在href中的锚标记未解析.可能是什么原因.
my anchor tag in href is not parsing. What might be the reason.
出于安全原因,UWP不支持嵌入式javascript.因此,像<a ng-click="jsfunc();"></a>
这样的代码将无法正常工作.请在JS文件中添加eventListener.
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.
这篇关于UWP应用程序是否支持Ajax?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!