Search
Left Quote    Copy from one, it's plagiarism; copy from two, it's research.
- Wilson Mizner    
Right Quote
 
[login] | [Register]
 

Getting Started with Ajax

by: misterhaan
Page: 3 of 4
(View All)


Ajax Requests

Ajax requests should usually be sent to the same server that served the page the Ajax JavaScript is running on, which means the ajax response will also come from that same server. The simplest case is responding with a static file (probably an xml or txt file), in which case all that needs to be done on the server is to make sure the file is in place. More often though it will be necessary to run a script on the server to process the data sent with the request and respond appropriately.


Headers


A consideration with using php (or any other server-side language) is that the server is probably set to send headers saying php output is html. With Ajax you may sometimes be using html, but often xml or plain text is more appropriate. For those cases, you should send the appropriate header for the format of the response. In php, this is done with the header function. other server-side languages have similar functions.

The header needed is Content-Type. For xml you want the value set to text/xml, and for plain text text/plain. it

1  |  2  |  3  |  4  |  
Next »


No Comments for this page.

You Must be logged in or a member to comment.


Tutorial Stats

Tutorial Stats

10,782 Views
0 Total Comments
5 Rating of 5 (1 Votes)

Options

Tutorial Options

· Login to Rate This Article
· Login to Post a Comment
· Read more by this author
Digg This Article! Del.icio.us: Bookmark This Article Reddit: Bookmark This Article BlinkList: Blink This Article! YahooMyWeb BlogMarks: Add This Mark! Furl: Save This Article Spurl: Mark This Article

Articles

Related    

· Learning JavaScript Basics
Your Article Here



"AllSyntax.com" Copyright © 2002-2017; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank