473,385 Members | 1,562 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,385 software developers and data experts.

Retrieve array through xmlHttpRequest/Ajax call

184 100+
Hi ,
can any one please say me how to retreive the array from another jsp thro' ajax call...


Expand|Select|Wrap|Line Numbers
  1.  
  2. <%@ include file="JspBean.jsp" %>
  3. <html>
  4. <head>
  5. <link rel="stylesheet" type="text/css" href="../static/js/dojox/grid/_grid/Grid.css">
  6.  
  7. <script type="text/javascript" src="../static/js/dojo/dojo.js" djConfig="isDebug:false, parseOnLoad: true"></script>
  8.  
  9. <script type="text/javascript">
  10.   dojo.require("dojox.grid.Grid");
  11. </script>
  12. <script type="text/javascript">   
  13.  
  14.     function postRequest(strURL) {
  15.     var xmlHttp;
  16.  
  17.         if (window.XMLHttpRequest) { // Mozilla, Safari, ...
  18.          var xmlHttp = new XMLHttpRequest();
  19.  
  20.        } else if (window.ActiveXObject) { // IE
  21.          var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  22.  
  23.        }
  24.     xmlHttp.open('POST', strURL, true);
  25.  
  26.     xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  27.  
  28.     xmlHttp.onreadystatechange = function() {
  29.  
  30.         if (xmlHttp.readyState == 4) {
  31.            updatepage(xmlHttp.responseText);
  32.            }   }
  33.  
  34.     xmlHttp.send(strURL);
  35.  
  36.         }     
  37.  
  38.         function updatepage(str){
  39.           this.field = str; 
  40.         }
  41. </head>
  42. <BODY>
  43.  
  44.  
  45.  
  46. <input type="button" name="submit" value="submit" onClick="postRequest('ajaxTest.jsp')">
  47. <BODY>
  48. </HTML>
  49.  
  50.  
ajaxTest.jsp
Expand|Select|Wrap|Line Numbers
  1.  
  2. <%@ page import="java.util.*"%>
  3. <%
  4. String[] tempArray = new String[5];
  5. for(int i=1;i<5;i++)
  6. {
  7. tempArray[i] = [ '1111', -111, 11, 111 ];
  8. }
  9. %>
  10.  

I need to get tempArray from ajaxTest.jsp at main jsp.
if i use xmlHttp.responseText i m not getting the array..
any one please help me..
Thank in Advance.
Jun 19 '08 #1
2 4621
r035198x
13,262 8TB
For starters, your Java code in ajaxTest.jsp is incorrect and won't compile. What did you want it to do?
Jun 19 '08 #2
acoder
16,027 Expert Mod 8TB
As for the array, you can't do it like that. You can either return a delimited string which you can split using split() (and, hey presto, you have an array!), or use JSON or XML and parse the response.

PS. I've changed the thread title to give the problem a better description.
Jun 19 '08 #3

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

Similar topics

42
by: Greg | last post by:
Hi, I've designed a bookmark in Ajax / PHP that I will put soon on sourceforge.net. But I've got an very tricky bug. I try it on some computers with Internet Explorer/Windows, Firefox...
5
by: ggk517 | last post by:
We are trying to develop an Engineering application using PHP, Javascript with Informix as the back-end. Is it possible to retrieve data using Javascript but by accessing the Database. Say...
1
by: mathewda | last post by:
Hey, I'm having a problem that I consider kinda weird that is alluding me at the moment. I've wrote some code that will set up an XMLHttpRequest, it then makes a call to open and send and sets the...
2
by: libsfan01 | last post by:
In IE6 i get an error: "XMLHttpRequest is undefined", whereas in other browsers (e.g. ie7) it works fine: var get; function getdata(region,page) { get = new XMLHttpRequest();...
10
by: HugeBob | last post by:
Hi All, I'm having a problem with a web app I'm writing. I have a form for which I'm going to validate one of the fields. I use AJAX to retrieve XML containing a list of valid entries. My app...
5
by: HugeBob | last post by:
Hi All, I've got a question about Asynchronous vs Synchronous mode with the XMLHttpRequest object. What are the ramifications of using one mode vs the other? If the script uses Asynchronous...
2
by: mndprasad | last post by:
Hi friends, Am new to AJAX coding, In my program am going to have two texbox which going to implent AJAX from same table. One box is going to retrieve the value of other and vice...
2
by: Michael Nemtsev [MVP] | last post by:
Hello, In the current application we have several httpmodules to process pages, and we have several pages with calls directly through the XMLHttpRequest. Now the requiremens is to detect the...
2
by: gradinafrica | last post by:
I'm trying to create a log out button that uses AJAX to call a php file which ends the current session: //logout.php <?php if (!session_start()); session_destroy(); //Destroys the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.