Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old April 10th, 2006, 04:25 AM
Noozer
Guest
 
Posts: n/a
Default 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.


  #2  
Old April 10th, 2006, 05:15 AM
Noozer
Guest
 
Posts: n/a
Default Re: Passing data via XMLHTTPRequest... How do YOU do it?


"Noozer" <dont.spam@me.here> wrote in message
news:s5k_f.11242$nf7.6613@pd7tw1no...[color=blue]
> 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.[/color]

....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?


  #3  
Old April 10th, 2006, 11:55 AM
Bob Barrows [MVP]
Guest
 
Posts: n/a
Default Re: Passing data via XMLHTTPRequest... How do YOU do it?

Noozer wrote:[color=blue]
> "Noozer" <dont.spam@me.here> wrote in message
> news:s5k_f.11242$nf7.6613@pd7tw1no...[color=green]
>> 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.[/color]
>
> ...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?[/color]

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"


  #4  
Old April 10th, 2006, 09:05 PM
Noozer
Guest
 
Posts: n/a
Default Re: Passing data via XMLHTTPRequest... How do YOU do it?

>> ...and to make matters worse, I just discovered JSON. Looks like a[color=blue][color=green]
>> breeze client side. But how to create the JSON object in my ASP code
>> on the server?[/color]
>
> http://www.google.com/search?ie=UTF-...tprequest+JSON[/color]

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?

%>


  #5  
Old April 10th, 2006, 09:25 PM
VK
Guest
 
Posts: n/a
Default Re: Passing data via XMLHTTPRequest... How do YOU do it?


Noozer wrote:[color=blue]
> 'How do I return this Person to my JSON enabled javascript?[/color]

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.

  #6  
Old April 11th, 2006, 12:58 PM
Anthony Jones
Guest
 
Posts: n/a
Default Re: Passing data via XMLHTTPRequest... How do YOU do it?


"Noozer" <dont.spam@me.here> wrote in message
news:nEy_f.57$7a.17@pd7tw1no...[color=blue][color=green][color=darkred]
> >> ...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?[/color]
> >
> >[/color][/color]
http://www.google.com/search?ie=UTF-...tprequest+JSON[color=blue]
>
> 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?
>
> %>
>[/color]

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




  #7  
Old April 14th, 2006, 02:45 PM
blueapricot416@gmail.com
Guest
 
Posts: n/a
Default Re: Passing data via XMLHTTPRequest... How do YOU do it?

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

  #8  
Old April 15th, 2006, 10:35 AM
Noozer
Guest
 
Posts: n/a
Default Re: Passing data via XMLHTTPRequest... How do YOU do it?


<blueapricot416@gmail.com> wrote in message
news:1145021709.243872.155340@u72g2000cwu.googlegr oups.com...[color=blue]
>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![/color]

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.



 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.