473,487 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 2271

"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
6163
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
10244
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
2445
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
26088
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
2274
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
1766
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'...
2
5871
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
5285
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
4971
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
7106
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
7137
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,...
1
4874
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
4565
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...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
600
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
267
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.