0

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

1
  • I solved this problem by adding some data to ajax result jsp and based on that I am changing the original jsp Commented Sep 12, 2012 at 6:42

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

7 Comments

any work around? Please I am not aware of JSON or never used it. Example for my scenario will be much helpful
can you update your question with a sample "responseText"? That would be useful to suggest any workarounds.
<b><font color="red"><s:actionerror /></font></b> <b><s:actionmessage /></b> this is jsp where I am sending my dispatcher and getting this action messages dynamically. I am trying to place some variable and data for workaround. :(
is this javascript part of a jsp and are those other <s:property ...> getting replaced with the appropriate values when they come to the client side?
this is written in another jsp. yes, values are being replaces properly by struts tags
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.