Jump to content

Send XML on to the client side as a .xml file


souravhainpagal

Recommended Posts

I have written a php script that prepares an XML and saves it onto the server itself...but I need the php to send the XML on to the client side...

Then I have a HTML file which will call a javascript function using the XML file as its parameter...

It is working fine if the XML is in the server...

BUT i dont know how to load an XML file from the client side itself...i.e. a local file...

 

Two problems :

 

1. Make the XML using data from the server side (No issues)...then SEND the xml to the client side using PHP (issue)

2. Use that same xml file sent to the client side...to call a javascript function from within an HTML file

 

An explanatory reply will be well appreciated !!!

Link to comment
Share on other sites

i dont want there to be any change on the server side...i dont want to save anything on the server side

the user enters certain form data and then the server side php prepares an XML...

 

i want that xml to be sent to the client side and then another page will use that XML to display the data...

 

can it be done ?

Link to comment
Share on other sites

And how does that page "display the data"? I'm talking about how the code, not the design, btw.

 

The biggest question, however, is why you're dead set on making things more difficult than they have to be? Why not just have the server-side code generate the result page straight away, save the file temporarily, or just save the raw input data in a database?

Link to comment
Share on other sites

i want that xml to be sent to the client side and then another page will use that XML to display the data...

 

Back to my original answer:

 

Ajax:

 

Using jQuery:

$.get("path/to/generate/my/xml.php", function(xml) {
  console.dir(xml);
  // use it however you would like..
}, 'xml');

 

Or use XSLT. If this is not what you want then you are gonna have to clarify yourself properly.

Link to comment
Share on other sites

And how does that page "display the data"? I'm talking about how the code, not the design, btw.

 

The biggest question, however, is why you're dead set on making things more difficult than they have to be? Why not just have the server-side code generate the result page straight away, save the file temporarily, or just save the raw input data in a database?

 

I want to do what you said exactly...

I want the php to prepare the XML and save the file temporarily...(BUT NOT IN THE SERVER)...temporary storage would do

Link to comment
Share on other sites

I want the php to prepare the XML and save the file temporarily...(BUT NOT IN THE SERVER)...temporary storage would do

 

You would have to have the browser force a download of the file. Then if you want your site to be able to use it again, the user would have to upload it.

 

Why are you trying to do it this way?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.