Getting Request parameters from Ajax Response

I am making ajax call to a java method for every 30 seconds. I am setting few request parameters in the java method.

How can I get them from ajax response.

<script LANGUAGE="JavaScript1.2">

var tId = window.setTimeout(function () { 
location.reload(true);
alert('<s:property value="#disableReload" />');
if('<s:property value="#disableReload" />' == "true"){
    alert("clearing");
}else{
    var url = 'moveETHAction_fetchExecutorData.action';
    var form = document.getElementById('moveForm');
    var params = Form.serialize(form) + '&ms=' +  new Date().getTime();
    form.action = "fetchExecutorData";
    var myAjax = new Ajax.Request(url, {method: 'post', parameters: params, onComplete: showResponseAction} );
}
}, 30 * 1000);

function showResponseAction(originalRequest){
alert(originalRequest.responseText);
    alert('<s:property value="#request[\'DISABLE_FLOW'\]" />');
document.getElementById('actionChange').innerHTML = originalRequest.responseText;
}
</script>

In Java method I am setting this parameter

request.setAttribute(GenericConstants.DISABLE_FLOW, false);

But I am not getting the updated value from the ajax

Answers


Any changes to the HttpServletRequest on the server side will not be visible on the client side. Moreover setAttribute method will not affect the incoming HTTP request string. It's additional store within HttpServletRequest to pass-around information on the server-side.

You need to add the information to the existing response, in a structured away (JSON is preferable for your client to convert into a javascript object right away and access the individual values within response). Hope this helps.


Need Your Help

XMLHttpRequest - Hitting serverside aspx method - 505 Internal Server Error

javascript c# asp.net ajax xmlhttprequest

I have coded an AJAX GET request using a XMLHttpRequest object. My problem is that the request is never hitting the server side code. I had a look at many forums and at stackoverflow and I dont rea...

Trying to create three classes and draw crayon box. How to draw crayons in constructor?

java user-interface jframe paint jcomponent

The instructions is to create a Crayon objects that have height, location, and color. The object should also draw the crayon. The program should have and hold 8 different crayons of different color...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.