Xml http request ajax

hi I’m developing an application with phonegap framework [beginner]
[Html 5 / css3 / jquery mobile / jquery / javascript] how I can display the content of the xml file in my application
using the technique to xml http request from ajax to display the contents of the xml file in the mobile query

I’m not sure I understand the question correctly.
Are you trying to fetch an XML file via Ajax and parse the result?

yes that’s it

for example
i have this data on xml file

 <car> <name>X</name><id>1</id></car>
 <car> <name>Y</name><id>2</id></car>
<car> <name>salim</name><id>3</id></car>

i want to display this on listview using ajax & xmlhttprequest

Well, a simple example would be:


<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8" />
    <title>Fetch and parse XML demo</title>

    <script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
        type: "GET",
        url: "cars.xml",
        dataType: "xml",
        success: function(xml){
            var id = $(this).find('id').text();
            var name = $(this).find('name').text();
            $("<li></li>").html(id + ": " + name).appendTo("ul");
        error: function(){
          console.log("An error occurred while processing XML file.");



This would produce:

  • 1: Audi
  • 2: Porsche
  • 3: Mercedes

hi thanks mate but how can i add the xmlhttprequest

The jQuery $.ajax() method replaces the browser native XMLHttpRequest object.
The result is the same, though.

You can read more here: http://www.sitepoint.com/jqxhr-object/

okey it works i tried and it’s cool
but now
i want to do the same thing with authentication login[admin] & password [ admin ]
i receive them from a xml file to login
and if there i put something else in the box i can’t login

and i searched for while but no results

Sorry, I don’t understand.
You receive the login credentials from an XML file?

i tested what you posted don’t work :(( for parsing xml data

Lol. Make up your mind.
Also, a bit more information would be nice if you need help with anything specific.

1 Like

sorry man i tested usuing other example but it did not work

You have to be more explicit about what you are trying to do, what code you have, what you expected to happen, what actually happened and so on.
Maybe read this: http://sscce.org/

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.