问题我提出AJAX调用到Server1即欧安会,一旦我得到的回应我发送响应为内容,以获得响应之后,Server2上ieyahoo服务器从那里我想刷新页面或至少将其重定向到同一页面。两个Ajax调用都正常工作。我发送的内容也保存唯一的问题是,我必须手动刷新页面才能看到更改。一旦内容保存在雅虎,我想刷新页面。我试过重新加载和重定向命令成功功能雅虎。但没有任何工作。我可以在HTTPfox中看到这两个Ajax调用,但不是重定向。问题需要
我打电话的URL与保存内容的网址不同,这就是为什么我需要刷新页面才能看到更改。即我在yahoo/save中保存,同时发送内容并查看yahoo/edit中的更改。
我不知道我哪里出错了。这是我使用的代码。任何人都可以建议我去哪里错了。如果我的问题不明确,请问我澄清更多。谢谢。
此代码是代码:
function handleButtonClick()
{
// Declare the variables we'll be using
var xmlHttp, handleRequestStateChange;
// Define the function to be called when our AJAX request's state changes:
handleRequestStateChange = function()
{
// Check to see if this state change was "request complete", and
// there was no server error (404 Not Found, 500 Server Error, etc)
if (xmlHttp.readyState==4 && xmlHttp.status==200)
{
var substring=xmlHttp.responseText;
alert(substring);// I am able to see the text which is returned by the server1 i.e csce
var handleSuccess = function(o)
{
if(o.responseText !== undefined)
{
console.log(o.responseText);
**window.location.reload()** // also I tried to redirect it to the same site but that also not works
}
};
var callback ={ success:handleSuccess, failure: function(x) {
console.error(x) }, argument: ['foo','bar']};
var request = YAHOO.util.Connect.asyncRequest('POST','http://yahoo.com******', callback, substring);
}
}
xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", "http://cse*****id=c6c684d9cc99476a7e7e853d77540ceb", true);
xmlHttp.onreadystatechange = handleRequestStateChange;
xmlHttp.send(null);
}
是的,如果你正在使用AJAX,使用它。不要重新加载您的页面,只需重新填充您的内容区域。 – aptwebapps 2010-11-13 16:06:42
感谢克里斯和aptwebapps ::我想刷新页面看到的变化,因为网页有不同的URI比我在哪里保存。而且我无法控制这些变化。我想要显示给用户的更改只是刷新页面。然后它会自动显示图片。你能建议任何其他的出路吗? – Judy 2010-11-13 19:44:54
如果你想在一个单独的页面上的内容,你将不得不通过cookie,会话变量,数据库等以某种方式传递数据。如果你使用AJAX和刷新,这是有点击败目的。任何可以详细说明的内容都可以帮助您更清楚地了解自己正在做的事情。 – 2010-11-13 22:39:35