Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am new to web programming and just started learning XML and AJAX. I am creating a social gaming website for my college project. I am confused at the point of using XML for AJAX in HTML5. As XHTML is replaced by HTML5 so is it ok to use XML or i should choose JSON (i know nothing about JSON but it is what I found in answers on web to the question related to choice between JSON and XML). My preference is XML because it is in my syllabus but I want to make sure that XML and HTML5 will not conflict.

share|improve this question
    
Did you ever check what AJAX is an acronym for? The XHR API? The markup language won't affect the code, and if you control both ends of the client server relationship then code with what you are happy with for now. –  JohnMark13 Sep 9 '13 at 15:04
    
You can use any kind of serialized data, XML, JSON, CSV, INI. JSON seems to be standard de facto this days, since it's much more readable and native to JavaScript. –  nirth Sep 9 '13 at 15:04
1  
this post is rather hard to read (wall of text). Would you mind editing it into a better shape? –  gnat Sep 9 '13 at 15:22
add comment

1 Answer

up vote 0 down vote accepted

You can encode the data sent to the server in any format you want and not interfere with the web page's standards.

The idiomatic thing to do is to just use JSON these days, but that is up to you.

It's also important to note that if you use a non HTML5 tag, the police aren't going to show up at your door and, unless your professor validates your site using a tool, he probably won't notice and it will render just fine.

Certain things in your page like <br> being more HTML5 compatible than <br/> will break XML compatibility, if that's what your asking. But the standard still leaves a clause allowing full XML compatibility in order to allow any page to comply with XML, AFAIK. Though, from the discussion in that thread, this is explicitly for backwards compatibility purposes with the older HTML standards.

share|improve this answer
    
shall i go deeper in XML before learning and starting use of AJAX or just a basic knowledge of XML schema, DTD etc will give me some base to dive into AJAX –  UDB Sep 9 '13 at 15:34
    
I should note that I think the term "XMLHttpRequest" was invented at a time when people thought XML was going to be the world's permanent, universal data-as-text storage format. The truth is, AJAX usually has little to do with XML. In modern days, HTML doesn't even have much to do with XML. While the basics of how XML works are useful to know, you do not need to understand the internals of DTD's, schemas, XSLT...and other stuff that a lot of programmers tend not to get so involved with. –  Katana314 Sep 9 '13 at 15:38
    
"DTD's, schemas" To reinforce your point, programmers didn't even define these when using XML years ago. They can be helpful for public APIs (things like XAML), but are relatively useless for a 1-off transport situation –  brian Sep 9 '13 at 15:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.