473,698 Members | 2,942 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP Page to capture AJAX XML post data

3 New Member
I have a script that catches javascript errors and sends them through ajax to a specified file through the POST proticol. I want to write an ASP file which can read this xml file and act on its response. I have a CGI/PERL equivalent but i'm not sure how to read the xml file in asp neatly:

use CGI;
use CGI::Carp qw(set_progname );
use XML::Simple;
my $request = CGI->new();

my $method = $request->request_method ();
# method must be POST
if ($method eq 'POST') {
eval {
my $content_type = $request->content_type() ;
if ($content_type eq 'text/xml') {
print $request->header(-status =>
'415 Unsupported Media Type', -type => 'text/xml');
croak "Invalid content type: $content_type\n ";
}
# when method is POST and the content type is neither
# URI encoded nor multipart form, the entire post
# is stuffed into one param: POSTDATA
my $error_xml = $request->param('POSTDAT A');
my $ref = XML::Simple::XM Lin($error_xml) ;
my ($name, $msg, $location) =
($ref->{'name'}, $ref->{'message'}, '');
$location = $ref->{'location'} if (defined($ref->{'location'})) ;
# this will change the name of the carper in the log
set_progname('C lient-side error');
my $remote_host = $request->remote_host( );
carp "name: [$name], msg: [$msg], location: [$location]";
};
if ($@) {
print $request->header(-status => '500 Internal server error',
-type => 'text/xml');
croak "Error while logging: $@";
} else {
# this response code indicates that the operation was a
# success, but the client should not expect any content
print $request->header(-status => '204 No content',
-type => 'text/xml');
}
} else {
print $request->header(-status => '405 Method not supported',
-type => 'text/xml');
croak "Unsupporte d method: $method";
}
Oct 31 '06 #1
4 4594
nedu
65 New Member
Hi,

Send the xml file which u have got. I will give you the asp code . .
Nov 2 '06 #2
Rich Halliwell
3 New Member
Hi,

Send the xml file which u have got. I will give you the asp code . .

Sure - I can send my ajax code if you contact me. The bulk of it can be found here:

http://www.xml.com/pub/a/2005/05/11/ajax-error.html

with slight modifications the returned xml looks like the following:

<?xml version=1.0"?>
<error>
<name>TypeError </name>
<message>Obje ct expected</message>
<location>htt p://www.somasdhkhsd af.com, function:foo()</location></error>

the important bit of this code is that the javascript ajax reads the state change of the asp page to state 204 and realises it has been successful.

I can provide you with any extra information you need

Thanks

Rich
Nov 5 '06 #3
nedu
65 New Member
<%
Set objXML = Server.CreateOb ject("Microsoft .XMLDOM")
Set objLst = Server.CreateOb ject("Microsoft .XMLDOM")
objXML.async = False
objXML.Load (Server.MapPath ("filename.xml" ))
If objXML.parseErr or.errorCode <> 0 Then
handle the error
End If

Set objLst = objXML.getEleme ntsByTagName("* ")

For i = 0 to (objLst.length – 1)

If objLst.item(i). nodeName = "error" Then
StrERR = objLst.item(i). text
Handle the Error here . . .

'Exit For
End If

Next
%>


Does thisa code help u . . . If u have any doubts mail me at mneduu@gmail.co m . .

Thanks & regards

(M. Nedu . .)
Nov 6 '06 #4
Rich Halliwell
3 New Member
Hi,

That isn’t quite the problem. First the asp page isn’t reading the xml file form the server – it has to get it from the request of the page. Second it is the return of the page which is causing issues. I can capture the xml crudely using the following:

<%@LANGUAGE="VB SCRIPT"%>
<%
Response.Conten tType = "text/xml"

set oXML = Server.CreateOb ject("Msxml2.DO MDocument")
oXML.setPropert y "ServerHTTPRequ est", True
oXML.async = False
oXML.load(Reque st)
Response.Status = "204 No Content"

Response.End


%>

But that doesn’t feedback successful to the ajax correctly

Thanks
Rich Halliwell
Nov 6 '06 #5

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

Similar topics

15
2064
by: Jake Barnes | last post by:
I'm trying to learn AJAX so tonight I sat down and came up with a little toy that I can do tests with. You can see it here: http://www.publicdomainsoftware.org/ajaxExperiment.htm I've got Stuart Langridge's book "DHTML Utopia: Modern Web Design using Javascript and DOM" which seems pretty good. It covers the basics. The next thing I'd like to do is add a Save button to this little page I came up with. I may use Sam Stephenson's...
4
1286
by: Tim | last post by:
Hello, I have a web page that a user enters in information and selects some products. On submit the page the info is saved to a db, connects to third party web apps and retrieves data, and third party data is saved. I want to be able on submit is redirect the user to a loading page (status) while the app is doing the above functionality and then when finished user is redirect to a new page (results). I really do not know where to...
14
23155
by: lmttag | last post by:
Hello. We're developing an ASP.NET 2.0 (C#) application and we're trying to AJAX-enable it. We're having problem with a page not showing the page while a long-running process is executing. So, we're looking for a way to display the page with a "please wait..." message while the process is running, and then, when the process is done, update the page with the actual results/page content. We have a page that opens another browser/page...
3
7828
by: radix | last post by:
Hello, I have a aspx page with ajax scriptmanger update panel etc. I also have public string variables on the aspx page. Whenever postback happens from Ajax update panel, at server side all the public string variables are reset to empty string. As if fresh page is loaded. How to preserve the page level variables during Ajax postback?
2
2008
by: ravisuguna | last post by:
Hi, I have a php page which has some checkboxes ,textfields and values.If I select a checkbox ,a particular value will be displayed in a textfield.I have a "go"button in the same page.I want the selected values and textfields to be displayed in the next page if i click the button.Pl guide me how to do this. I am sending the sample code below. arical.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
2
2727
by: JM_newsgroups | last post by:
Hi, When I do a postback on a particular AJAX-enabled page, I get a popup that says: "Sys.WebForms.PageRequestManagerParserErrorException: The message received could not be parsed. . . . " It comes and goes, and I only get the message once. A second submit does not produce the message. Any ideas? I can provide a screen capture of the dialog box if needed. I am not doing a call to Response.Write(), filters, etc.
2
3312
by: Max | last post by:
I recently moved to ASPnet Ext 3.5 What I can't get with Ajax and History browser managemet is this: User fills some fields (dropdown and textbox) on page 1 (all are in an update panel) User clicks Submit Button I write the data into a DB I add a history point with ScriptManager to be able to get back to this point with browser back button Page 2 is loaded with a response.redirect() command
5
3159
by: vasilis | last post by:
I have a list box in a site with which I capture a selected value with the onChange event using the capture_value() function (code listed below). This function passes 2 arguments, i.e., 'str' which is the selected list box value and 'passed_url' which is a passed url for running a php script (which contains some url query parameters, e.g. 'somescript.php?var1=value1&var2=value2&var3=value3'). The capture_value() function actually sends a...
0
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9031
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8876
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7741
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6531
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4372
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.