在做两个AJAX调用后刷新页面问题 [英] problem in refreshing the page after making two ajax calls

查看:123
本文介绍了在做两个AJAX调用后刷新页面问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题我提出AJAX调用到Server1即欧安会,一旦我得到了我送的响应,内容从那里得到响应后到Server2 ieyahoo服务器的响应我要刷新页面或ATLEAST重定向到同一页面。这两个Ajax调用工作正常。我送也保存了唯一的问题的内容是,我必须手动刷新页面才能看到的变化。我想刷新页面,一旦内容保存在雅虎。我试过的重新加载重定向在雅虎成功的功能命令。但没有任何工程。我可以看到在HTTPfox而不是重定向两个Ajax调用。

从我拨打电话的网址是从哪儿内​​容保存这就是为什么我需要刷新页面以查看更改的网址不同。比如我现在的储蓄在雅虎/在发送的内容,看到在雅虎/编辑更改保存。

我不知道我要去的地方错了。这是我的code我使用。任何人都可以提出我要去的地方错了。如果我的问题是不明确的好心就问我澄清了。谢谢你。

这code是code:

 函数handleButtonClick()
{
//声明,我们将要使用的变量
VAR XMLHTTP,handleRequestStateChange;

   //定义函数被调用时,我们的AJAX请求的状态变化:
handleRequestStateChange =功能()
{
    //检查,看看这个国家的变化是请求完成,并
    //没有服务器错误(404未找​​到,500服务器错误,等等)
    如果(xmlHttp.readyState == 4和&安培; xmlHttp.status == 200)
    {
        VAR子= xmlHttp.responseText;

        警报(子); //我能看到它是由服务器1,即欧安会返回文本
VAR handleSuccess =功能(O)
 {
   如果(o.responseText!== undefined)的
   {
     执行console.log(o.responseText);
 ** window.location.reload()** //我也试图将其重定向到同一网站,但还没有作品


  }
 };
VAR回调= {成功:handleSuccess,失败:功能(X){
console.error(X)},参数:['富','酒吧']};
VAR请求= YAHOO.util.Connect.asyncRequest('POST','HTTP://yahoo.com******,回调,子);

    }
}

XMLHTTP =新XMLHtt prequest();
xmlHttp.open(GET,HTTP:// CSE ***** ID = c6c684d9cc99476a7e7e853d77540ceb,真正的);
xmlHttp.onreadystatechange = handleRequestStateChange;
xmlHttp.send(空);
 }
 

解决方案

你只是想显示在您的网页内容?你为什么不尝试沿着的document.getElementById('DIVID')东西线的innerHTML = xmlHttp.responseText;?

使用DIVID是要填的内容div的ID。

Problem I am making ajax call to server1 i.e. csce and once I got the response I am sending the response as contents to server2 i.e.yahoo server after getting response from there I want to refresh the page or atleast redirect it to the same page. Both ajax calls are working fine. The contents I am sending are also saved the only problem is that I have to manually refresh the page to see the changes. I want to refresh the page once the contents are saved on yahoo. I tried reload and redirect commands in success function of yahoo. But nothing works. I can see the both ajax calls in the HTTPfox but not the redirect.

The url from which i am making calls is different from the url where contents are saved thats why I need to refresh the page to see the changes. i.e. I am saving in yahoo/save while sending contents and seeing changes at yahoo/edit.

I am not sure where I am going wrong. Here is my code I am using. Can anyone suggest where I am going wrong. If my problem is not clear kindly do ask me to clarify more. Thanks.

This code is the code:

 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);
 }

解决方案

Do you just want to display the content in your page? Why don't you try something along the lines of document.getElementById('divID').innerHTML = xmlHttp.responseText;?

With divID being the id of a div that you want to fill the content with.

这篇关于在做两个AJAX调用后刷新页面问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆