473,408 Members | 2,027 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,408 software developers and data experts.

Passing data via XMLHTTPRequest... How do YOU do it?

I've been doing some reading about "AJAX" and it sounds pretty interesting.
While I can make it work, it seem like I'm doing much of it the "hard way".
I was wondering what kind of code that others use to pass data via
XMLHTTPRequest.

My code is usually in ASP, with VBScript or Javascript for the client side
of things. I've done a bit of PHP as well. Definately not an expert by any
means, but I do understand programming - I just don't know what
elements/objects/methods/etc. are available.

So, consider the following and tell me what you'd do. Sample code is great
as well.
Address book type web application, but page contains info from two seperate
queries. User enters a name in one area of the page and clicks Search. The
XMLHTTPRequest object hits an ASP page and populates the related fields
(Name, age, SIN, etc.) in the clients screen, keeping other elements in the
page intact. What if the returned data contained a binary, like a photo?

Would you have the ASP page return a simple HTML document and parse out the
"responseText" property to find your field data? How about having the ASP
page generate a XML response and using the "responseXML" property as an
"object" containing the required information?

I guess I'm just trying to get my head around how I'd be passing different
types of information from my server side page using the XMLHTTPRequest
object. It seems like such a simple thing, but looks much more complicated
in any samples that I can find.
Apr 10 '06 #1
7 2273

"Noozer" <do*******@me.here> wrote in message
news:s5k_f.11242$nf7.6613@pd7tw1no...
I've been doing some reading about "AJAX" and it sounds pretty
interesting. While I can make it work, it seem like I'm doing much of it
the "hard way". I was wondering what kind of code that others use to pass
data via XMLHTTPRequest.


....and to make matters worse, I just discovered JSON. Looks like a breeze
client side. But how to create the JSON object in my ASP code on the server?
Apr 10 '06 #2
Noozer wrote:
"Noozer" <do*******@me.here> wrote in message
news:s5k_f.11242$nf7.6613@pd7tw1no...
I've been doing some reading about "AJAX" and it sounds pretty
interesting. While I can make it work, it seem like I'm doing much
of it the "hard way". I was wondering what kind of code that others
use to pass data via XMLHTTPRequest.


...and to make matters worse, I just discovered JSON. Looks like a
breeze client side. But how to create the JSON object in my ASP code
on the server?


http://www.google.com/search?ie=UTF-...tprequest+JSON
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Apr 10 '06 #3
>> ...and to make matters worse, I just discovered JSON. Looks like a
breeze client side. But how to create the JSON object in my ASP code
on the server?


http://www.google.com/search?ie=UTF-...tprequest+JSON


Thanks. I've actually visited many of those pages.

While I can find many examples of client side scripting, I'm having a hard
time finding examples of server side code generating a practical response.

<%
'Delcare and instanciate a "Person" object
dim oPerson
set oPerson = new cPerson

'Fill our object with data
oPerson.name="Bob Smith"
oPerson.age=36
oPerson.address.street="123 Main Street"
oPerson.address.city="Salem"
oPerson.address.state="OR"

'How do I return this Person to my JSON enabled javascript?
'How about XML enabled javascript?

%>
Apr 10 '06 #4
VK

Noozer wrote:
'How do I return this Person to my JSON enabled javascript?


Go to the official JSON site <http://www.json.org> and get the most
appropriate server-side module. I hope that between PHP, Perl and
Python you'll find something that fits your server.

Apr 10 '06 #5

"Noozer" <do*******@me.here> wrote in message
news:nEy_f.57$7a.17@pd7tw1no...
...and to make matters worse, I just discovered JSON. Looks like a
breeze client side. But how to create the JSON object in my ASP code
on the server?

http://www.google.com/search?ie=UTF-...tprequest+JSON
Thanks. I've actually visited many of those pages.

While I can find many examples of client side scripting, I'm having a hard
time finding examples of server side code generating a practical response.

<%
'Delcare and instanciate a "Person" object
dim oPerson
set oPerson = new cPerson

'Fill our object with data
oPerson.name="Bob Smith"
oPerson.age=36
oPerson.address.street="123 Main Street"
oPerson.address.city="Salem"
oPerson.address.state="OR"

'How do I return this Person to my JSON enabled javascript?
'How about XML enabled javascript?

%>


If you're serious about JSON then why not use Javascript server side as
well?


Apr 11 '06 #6
I have been wondering the same thing.

It looks like you are using Classic ASP, and it turns out you can just
make the XMLHTTPRequest to an ASP page that sends a regular
Response.Write with the string you want to return!

See:
http://tinyurl.com/nvbcf

Hope this helps,
Blue Apricot

Apr 14 '06 #7

<bl************@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
I have been wondering the same thing.

It looks like you are using Classic ASP, and it turns out you can just
make the XMLHTTPRequest to an ASP page that sends a regular
Response.Write with the string you want to return!


But... I want raw data returned in the response. The javascript on the
client side will do the work of presenting it to the user.

I'm trying to figure out how I should be generating and returning multiple
pieces of data from the server, to be handled by the client side script.

In my previous example...

oPerson.name="Bob Smith"
oPerson.age=36
oPerson.address.street="123 Main Street"
oPerson.address.city="Salem"
oPerson.address.state="OR"

.... I'd want my javacript to be able to pull these values from the response,
whether it be in plain HTML, XML or JSON. Right now, JSON "appears" to be
the best way to handle this on the client side - but for text data I could
even just fill in a bunch of <spans> and refer to thier InnerText by their
ID.

Apr 15 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: Oscar | last post by:
I am looking for a way to pass an ADO recordset that has been retrieved in an ASP page to another HTML-page. Is there someone who can provide me with a small sample or a link to see how this is...
5
by: Jarson | last post by:
My JavaScript is trying to POST data to a CGI script (Perl) using XMLHttpRequest. My CGI server gets different data from IE than Mozilla Firefox. // For Mozilla, req = new XMLHttpRequest(); //...
10
by: vbMark | last post by:
Hello, I am doing this: window.location="page2.php?subj="+subj+"&body="+body; to send information to another page. However, I don't want that second page to show up or display in any way....
3
by: NextOne | last post by:
Hi ! Is it possible to send an AJAX XMLHttpRequest using prototype.js API for a multipart/form-data ? I already done parsing form parameters and sending GET/POST request, but does this work...
7
by: Noozer | last post by:
I've been doing some reading about "AJAX" and it sounds pretty interesting. While I can make it work, it seem like I'm doing much of it the "hard way". I was wondering what kind of code that others...
2
by: kasper48 | last post by:
Hello, I am using the following script to load content into a DIV tag on my webpage when an onclick calls the 'loadXMLDiv1' function...I am trying to add a section variable in the 'loadXMLDiv1'...
3
by: one.1more | last post by:
How do i post the form data to different php files at once. I tried the following code but it doesn't work. the data is sent only to the first php file. <form method="post" action="insert.php"...
2
by: Geoff Cox | last post by:
Hello, The code below is aimed at passing the date in the yyyyMMdd format from the javascript calendar in an html file to the php in a another file which then searches a MySQL database. For...
1
by: Tarik Monem | last post by:
OK, I'm pretty sure this cannot work because I'm trying to use JavaScript (client-side) to write to an xml file (which is server-side) using XMLHttpRequest. Can I use PHP do what I'm trying to do?...
2
by: Wizfrog | last post by:
Hello, I'm working with a pretty large XML file, but I really only need to display a few things that requires quite a few transforms. I already limited to the transforms to the data i need to...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.