使用AngularJS检查URL是否可用 [英] Check if URL available or not using AngularJS
本文介绍了使用AngularJS检查URL是否可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个像 www.testsite.com/mypage
这样的URL.我需要使用AngularJS检查URL是否存在.
I have one URL like www.testsite.com/mypage
.I need to check if URL is exist or not using AngularJS.
有可能吗?任何人都可以建议.
Is it possible. Any one please suggest.
推荐答案
您需要使用服务器端api(或服务)来包装此测试,因为在JavaScript中嵌入这种测试被认为是跨域查询(可以视为攻击).
You need to wrap this test by using a server-side api (or service) because embedding this kind of test in JavaScript is considered as cross-domain-query (could be considered as an attack).
例如,假设您在/myRemoteSiteTester
下写了一个包装器那么我会尝试这样的事情:
For example, consider you have written a wrapper under /myRemoteSiteTester
then I would try whith somethings like that:
$http.get('/api/myRemoteSiteTester', {params: {target: myUrl}})
.success(function(data) {
alert(data);
});
这篇关于使用AngularJS检查URL是否可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文