跨网域问题(在IE中无法在其他浏览器中使用)请回复 [英] Cross Domain issue(Working in IE not in other browser) Please Reply
问题描述
大家好
我正在使用ajax调用从URL提取数据.它给了我一个json对象.
当我运行应用程序时,该页面在IE中工作正常,并且符合
该页面正在访问不受其控制的信息.这构成了安全威胁.要继续吗?
但这不适用于其他浏览器,如FireFox,Chrome,Safari等.
我不知道这是什么问题...请向我解释为什么会发生以及如何解决该问题..
我的代码:
Hi all
I am fetching data from a URL using ajax call.it is giving a json object to me.
When i run the application the page is working fine in IE with a conformation that
The Page is accessing information that is not under its control.This poses a security rick.Do you want to continue?
but that is not working in other browser like FireFox,Chrome,Safari etc.
i don''t know what is the problem ...please explain me why it is occurring and how to solve the issue..??
My Code:
<html>
<head>
<script type="text/javascript">
function Search() {
var url = "wwwourgoalplancom";
var userInput = document.getElementById("searchInput").value;
var searchURL = "http://192.168.9.11/userInput ";//Form this URL json formatted data is present.
$.ajax({
url: searchURL,
type: 'POST',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function (data) {
try {
alert(data);
}
catch (err) {
alert(err);
}
}
});
}
</script>
</head>
<body>
<input type="search" id="searchInput" autofocus />
<input type="button" name="Submit" value="Search" id="btnSearch" onclick="Search()" />
</body>
</html>
尝试中的数据来自IE,其他浏览器中为null.
请帮忙
在此先感谢您.
data inside try is coming in IE and null in other browsers.
Please help
Thanks in advance.
推荐答案
.ajax({ 网址:searchURL, 类型:' POST', dataType:' json', contentType:' application/json; charset = utf-8', 成功:功能(数据){ 尝试 { 警报(数据); } 捕获(错误){ 警报(err); } } }); } < / 脚本 > < /head > < 正文 > < 输入 =" 搜索" id searchInput" 自动对焦 / > < 输入 =" 按钮" 名称 提交" 值 =" 搜索" id btnSearch" onclick =" span> / > < /body > < /html >
.ajax({ url: searchURL, type: 'POST', dataType: 'json', contentType: 'application/json; charset=utf-8', success: function (data) { try { alert(data); } catch (err) { alert(err); } } }); } </script> </head> <body> <input type="search" id="searchInput" autofocus /> <input type="button" name="Submit" value="Search" id="btnSearch" onclick="Search()" /> </body> </html>
尝试中的数据来自IE,其他浏览器中为null.
请帮忙
预先感谢.
data inside try is coming in IE and null in other browsers.
Please help
Thanks in advance.
请诊断浏览器的安全设置,这与您的代码无关.
谢谢,
Ambesha
Please diagnosis the browser security setting , it is not an issue of your code .
Thanks,
Ambesha
这篇关于跨网域问题(在IE中无法在其他浏览器中使用)请回复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!