Generate report xml and download to client

Posted on 2013-02-06
Last Modified: 2013-02-07
Since i am beginner of Jquery, i'd like to ask how i can use Jquery to ask sever generate xml report and download to client:

1- from client i post typeReport, and <key, value> pair to server using $.ajax(...)
2- from server depending on the typeReport, it create xml file and download to client to display.

Could you please help? Thanks,

Question by:mtran888
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 53

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 500 total points
ID: 38863112
If you are really unsure of this, I would break this out into several separate questions. (Posting data, Receiving and  processing data to create xml, Reading xml )

In short you are going to use jquery ajax to send your data.   Before posting data, you first need to set up your page you are posting data to to receive the data, do any error checking, data scrubbing, validation, processing and output to xml.

Now you can post your data with ajax to somePage.php or asp(x)

  type: "POST",
  url: "somePage.php",
  data: { name: "John", location: "Boston" }
}).done(function( msg ) {
  alert( "Data Saved: " + msg );

Once you get the alert and can see your data, replace the alert line with a more detailed function to read the xml Parsing your xml takes special set up based on how you have set up y our xml page.  Get the first 2 steps done first, then create a new question on parsing the xml you created.

Author Comment

ID: 38864162

Thanks so much for your advise. Since I am the first time use web app. what do you mean"you first need to set up your page you are posting data to to receive the data"

Thanks again.

LVL 53

Accepted Solution

Scott Fell,  EE MVE earned 500 total points
ID: 38864251
Ajax sends some data to a receiving page that processes the data.  The receiving page would be just as if you were using it to post form data to.

The code below

  type: "POST",
  url: "somePage.asp",
  data: { name: "John", location: "Boston" }
}).done(function( msg ) {
  alert( "Data Saved: " + msg );

is the same as

<form action="somePage.asp" method="post">
<input type="hidden" name="name" value="john">
<input type="hidden name="location" value="boston">
<button type="submit">Submit</button>
response.write request.form("name")&" "&request.form("location")

With the main difference ajax code is on page 1, posting to page 2.  Page 2 processes the data and displays it as html, text, json or xml.  Finally page 1 reads the data from page 2 and displays it using, ".done(function( msg ) {" where msg is the output from page 2.

Since you are just starting out, take this one step at a time.  I would first make a page 2 with static data that just outputs some pre made xml, text, json or html.  Then try and use your ajax to call page 2 and display it.  

Once that works, you need to build page 2 to accept data from the ajax call on page 1 and process it and display the output in json, xml, html or text.

Author Closing Comment

ID: 38865843
Thanks Padas. I really appreciate your explanation.
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 38865940
Great! Thanks!

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
youtube blocking politics 4 104
Access RV042 GUI / Browser Issues 25 88
IE11 cannot send an email using a gmail account 2 42
Problem to copy file 14 91
SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question