472,123 Members | 1,330 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Is This "AJAX"?

I have some javascript in a standard HTML page that uses the ubiquitous
"XMLHttpRequest" to send data to a remote ASP page.

If that page "answers back" by sending a string using a simple
Response.Write, which I then use in the original HTML page to
dynamically update stuff, is this "AJAX"?

Specifically, is there anything "wrong" with sending back info from
classic ASP pages using simple Response.Writes? (Is there usually
something more required in the "answer back"? Or something that
Response.Write might not be sending, like an appropriate header "AJAX"
header?)

I mean, what I have done works! -- so I wonder if I am missing
something? It seems so easy to do -- I _MUST_ be missing something?
Right?

Thanks,
Blue Apricot

Apr 14 '06 #1
6 2358


bl************@gmail.com wrote:
I have some javascript in a standard HTML page that uses the ubiquitous
"XMLHttpRequest" to send data to a remote ASP page.

If that page "answers back" by sending a string using a simple
Response.Write, which I then use in the original HTML page to
dynamically update stuff, is this "AJAX"?


You can call it AJAX as it uses XMLHttpRequest. You could refuse to call
it AJAX if you don't exchange XML as the X in AJAX stands for XML. But
noone cares anymore whether that terms makes much sense or whether any
of the components (Asynchronous Javascript and Xml) are really used.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Apr 14 '06 #2
SOrry, it is not so much the "term" I am wondering about.

What I am wondering is:

1. Can I use "Response.Write" to send info back to the XMLHttpRequest?
2. Is there any shortcomings to doing so?

Thanks,
B.A.

Apr 14 '06 #3


bl************@gmail.com wrote:
1. Can I use "Response.Write" to send info back to the XMLHttpRequest?
2. Is there any shortcomings to doing so?


Sure you can use Response.Write in an ASP page to write stuff as the
response to an HTTP request. That is what Response.Write is meant for.
And it does not matter if the HTTP request is e.g. made by the browser
because the user asked to load a URI or e.g. by some script executed in
the browser. Processing a HTTP request and writing a response with ASP
does not depend on how the request was made on the client.
As with all responses your ASP makes, you should decide what
Content-Type to send and indicate that with e.g.
Response.ContentType = "application/xml"
or
Response.ContentType = "text/plain"

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Apr 14 '06 #4
Yep!, you are right. You can also send the response data in an XML format and
parse it in the client side to display them.

- Rafiq
http:/www.ajaxtoday.com

"bl************@gmail.com" wrote:
I have some javascript in a standard HTML page that uses the ubiquitous
"XMLHttpRequest" to send data to a remote ASP page.

If that page "answers back" by sending a string using a simple
Response.Write, which I then use in the original HTML page to
dynamically update stuff, is this "AJAX"?

Specifically, is there anything "wrong" with sending back info from
classic ASP pages using simple Response.Writes? (Is there usually
something more required in the "answer back"? Or something that
Response.Write might not be sending, like an appropriate header "AJAX"
header?)

I mean, what I have done works! -- so I wonder if I am missing
something? It seems so easy to do -- I _MUST_ be missing something?
Right?

Thanks,
Blue Apricot

Apr 27 '06 #5
I have question here Martin.

Is there anyway (DHTML) to detect if the content is xml file or text.

right now what I am doing is

'xmlstring = xml file or error code in like "Error:- Error is generated so
and so"

Response.ContentType = "application/xml"
Response.write xmlstring
response.end

my client page DHTML looks like

var sTemp = xmlhttp.responseText
var i = sTemp.indexOf("Error:-") // instead of doing this I wish to detect
if thats xml or not, if xml means go ahead if not display error
if (i >= 0)
{
//display error
return false
}
var nodes = xmlhttp.responseXML.documentElement.getElementsByT agName('abcd')

Martin Honnen wrote:
bl************@gmail.com wrote:
1. Can I use "Response.Write" to send info back to the
XMLHttpRequest? 2. Is there any shortcomings to doing so?


Sure you can use Response.Write in an ASP page to write stuff as the
response to an HTTP request. That is what Response.Write is meant for.
And it does not matter if the HTTP request is e.g. made by the browser
because the user asked to load a URI or e.g. by some script executed
in the browser. Processing a HTTP request and writing a response with
ASP does not depend on how the request was made on the client.
As with all responses your ASP makes, you should decide what
Content-Type to send and indicate that with e.g.
Response.ContentType = "application/xml"
or
Response.ContentType = "text/plain"

May 5 '06 #6

"abcd" <ab**@abcd.com> wrote in message
news:ed**************@TK2MSFTNGP04.phx.gbl...
I have question here Martin.

Is there anyway (DHTML) to detect if the content is xml file or text.

right now what I am doing is

'xmlstring = xml file or error code in like "Error:- Error is generated so
and so"

Response.ContentType = "application/xml"
Response.write xmlstring
response.end

my client page DHTML looks like

var sTemp = xmlhttp.responseText
var i = sTemp.indexOf("Error:-") // instead of doing this I wish to detect
if thats xml or not, if xml means go ahead if not display error
if (i >= 0)
{
//display error
return false
}
var nodes = xmlhttp.responseXML.documentElement.getElementsByT agName('abcd')
A client can reasonably expect to test the content type header to determine
the type of content received. If you are sending plain text then really
ought to be setting the Response.ContentType to text/plain.

if (xmlResponse.getResponseHeader("Content-Type").indexOf("application/xml") -1)

//xml was sent

Personally I prefer to allways send XML even if there is an error. I use
error xml along the lines of:-

<error>
<number>5</number>
<description>Invalid Procedure Call</description>
<source>Somewhere</source>
<error>

Then test if the documentElement has the tag name 'error'.

Anthony.
May 6 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by John Willems | last post: by
7 posts views Thread by Larry Bud | last post: by
3 posts views Thread by Tony | last post: by
1 post views Thread by Tony Lawrence | last post: by
3 posts views Thread by caston | last post: by
5 posts views Thread by Sommer.pde | last post: by
11 posts views Thread by Jonathan Wood | last post: by

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.