473,387 Members | 1,476 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

JSP + Javascript + ajax: value not set unless page refreshed

This is my code I use in Jsp file.
Expand|Select|Wrap|Line Numbers
  1. <%! int b = 0; %>
  2. ...
  3. <script language="JavaScript">
  4. ...
  5. function processStateChange() {
  6. if (req.status == 200) {
  7.  
  8. <%
  9. b = b +1; //Doan 1
  10. %> 
  11.  
  12. var c = "<%=b%> //Doan 2
  13. }
  14. }
  15. </script
The value of c = b only I press refresh button of IE.
Please help me resolve this proplem. Thank alot
Oct 19 '06 #1
1 1576
acoder
16,027 Expert Mod 8TB
Ajax doesn't work like that. You need to call a JSP script to change the value and then set c to the responseText of the XMLHttpObject. See an example.
May 22 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Matt Jensen | last post by:
Howdy all Hopefully I can explain my problem straightforwardly. In it's simplest explanation, what I want to do is have a hyperlink that, when clicked, executes some client side JavaScript and...
6
by: turnitup | last post by:
Dear all, I would like to implement a session timeout feature so that browsers are automatically logged out if there is no activity after a certain time. I know that this can be done with...
0
by: arunprabu | last post by:
Hi, I have a problecm with the AJAX request in my webpage. I have some filters on top of the page. I have a submit button and an empty div below the filters. Some of the filters have ajax...
5
by: Paolo | last post by:
Hi to everybody, i have this problem. I need to refresh an input text field inside a form on a PHP web page with a value notfied by a software written in ANSI C language. I don't want that my C...
7
by: shil | last post by:
Hi all, Can any one direct me in how to use javascript confirm() function when a condition is met from codebehind. I don't want to attach this to a button. When I submit the page, I want to...
8
by: =?Utf-8?B?QW1yaXQgS29obGk=?= | last post by:
Okay, after much research, I have discovered a few interesting things in ASP.NET. I have a MasterPage that has a WebForm on it and it looks like this: <body> <form id="controls"...
22
by: Dan Rumney | last post by:
Hi all, I've been writing Javascript for quite a while now and have, of late, been writing quite a lot of AJAX and AJAX-related code. In the main, my dynamically generated pages are created...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.