I have my application on appspot. This is on personal domain account.
我在appspot上有我的应用程序。这是个人域帐户。
I have put an iGoogle Gadget on iGoogle Page of my gmail account.
我在我的Gmail帐户的iGoogle页面上放了一个iGoogle小工具。
I am sending ajax request from my gadget like :
我从我的小工具发送ajax请求,如:
$(document).ready(function(){
jQuery.ajax({
type: "get",
url: "http://searcegadget2.appspot.com/requestServlet",
success: function(msg){
alert(msg);
if(msg.search('tr') != -1){
id = msg.split('</tr>').length - 1;
//alert(id);
$('#amountTable').append(msg);
difference();
}else if(msg.search('form') != -1){
$('#gadget').css('display', 'none');
document.write(msg);
}else if(msg.search('http') != -1){
document.location = msg;
$('#amountTable').append(msg);
}
},error: function(XMLHttpRequest, textStatus, errorThrown){
alert("XMLHttpRequest: " + XMLHttpRequest.responseText);
alert("textStatus : " + textStatus.responseText);
alert("errorThrown : "+ errorThrown);
}
});
});
There is nothing shown in XMLHttpRequest & errorThrown alerts. But, there is "error" shown in textStatus !
XMLHttpRequest和errorThrown警报中没有显示任何内容。但是,textStatus中显示“错误”!
Now, the link "http://searcegadget2.appspot.com/requestServlet" is shown in red and when I open the "http://searcegadget2.appspot.com/requestServlet" from Inspect Element in Mozilla, it returns me the required data as well ! How do I attach it to my gadget ?
现在,链接“http://searcegadget2.appspot.com/requestServlet”以红色显示,当我从Mozilla的Inspect Element打开“http://searcegadget2.appspot.com/requestServlet”时,它返回了我所需的数据也是!如何将其附加到我的小工具?
My request servlet is in java. For reference : jQuery.ajax()
我的请求servlet是在java中。供参考:jQuery.ajax()
Also, I have tested this web application. That is working properly !
此外,我已经测试了这个Web应用程序。这工作正常!
1 个解决方案
#1
0
Without seeing an error message or and error code it's hard to tell what your issue is, but from your post, I would think that it's a cross-domain scripting issue. You can't do an XMLHttpRequest from a different domain. (e.g. gmail.com cannot do an XMLHttpRequest to searcegadget2.appspot.com without throwing an error).
没有看到错误消息或错误代码,很难说出你的问题是什么,但是从你的帖子中,我认为这是一个跨域脚本问题。您无法从其他域执行XMLHttpRequest。 (例如,gmail.com无法对searcegadget2.appspot.com执行XMLHttpRequest而不会抛出错误)。
Try add the Access-Control-Allow-Origin header to the response of the controller which handles your requestServlet endpoint.
尝试将Access-Control-Allow-Origin标头添加到处理requestServlet端点的控制器的响应中。
For more information of the Access-Control-Allow-Origin header, see this thread:
有关Access-Control-Allow-Origin标头的详细信息,请参阅以下主题:
Access-Control-Allow-Origin Multiple Origin Domains?
Access-Control-Allow-Origin多个源域?
#1
0
Without seeing an error message or and error code it's hard to tell what your issue is, but from your post, I would think that it's a cross-domain scripting issue. You can't do an XMLHttpRequest from a different domain. (e.g. gmail.com cannot do an XMLHttpRequest to searcegadget2.appspot.com without throwing an error).
没有看到错误消息或错误代码,很难说出你的问题是什么,但是从你的帖子中,我认为这是一个跨域脚本问题。您无法从其他域执行XMLHttpRequest。 (例如,gmail.com无法对searcegadget2.appspot.com执行XMLHttpRequest而不会抛出错误)。
Try add the Access-Control-Allow-Origin header to the response of the controller which handles your requestServlet endpoint.
尝试将Access-Control-Allow-Origin标头添加到处理requestServlet端点的控制器的响应中。
For more information of the Access-Control-Allow-Origin header, see this thread:
有关Access-Control-Allow-Origin标头的详细信息,请参阅以下主题:
Access-Control-Allow-Origin Multiple Origin Domains?
Access-Control-Allow-Origin多个源域?