Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 806489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:15:05+00:00 2026-05-15T00:15:05+00:00

I am using jQuery and trying to load a variable in place of a

  • 0

I am using jQuery and trying to load a variable in place of a named xml file.
My Code:

$(document).ready(function() { 
        // bind 'myForm' and provide a simple callback function 
        $('#theForm').ajaxForm(function(responseXML2) { 

            var myxml = responseXML2;
            alert(responseXML2);
            displayResult();


           }); 
}); 
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
  {
  alert("loading xmlhttprequest");
  xhttp=new XMLHttpRequest();
  }
else
  {
  alert("loading activeX");
  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
alert("bottom load");
xhttp.open("GET",dname,false);
xhttp.send();
return xhttp.responseXML;
}

function displayResult()
{
alert("setting vars");

alert("displayResult called");

//xml=loadXMLDoc(responseXML2);  //tried this and the line below, among others
xml=responseXML2;
alert("xmlDocLoaded");
xsl=loadXMLDoc("xslt-test.xsl");
alert("XSLloaded");
// code for IE
if (window.ActiveXObject)
  {
  alert("IE");
  ex=xml.transformNode(xsl);
  document.getElementById("ieiresponse").innerHTML=ex;
  }
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
  {
  alert("notIE");
  xsltProcessor=new XSLTProcessor();
  xsltProcessor.importStylesheet(xsl);
  resultDocument = xsltProcessor.transformToFragment(xml,document);
  document.getElementById("ieiresponse").appendChild(resultDocument);
  }
}

In the code above I want to have:

//xml=loadXMLDoc(responseXML2);  //tried this and the line below, among others
xml=responseXML2;

instead of a named file:

xsl=loadXMLDoc("example.xml");

When I run through the code, it works if I name the file, but when I use the variable, (which does show up in alerts, so is being pulled), it stops the code at the above line (placing the variable as the xml file)

Any help would be much appreciated! Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T00:15:05+00:00Added an answer on May 15, 2026 at 12:15 am

    From the comments:

    I essentially want to post a form to a server,
    receive the response back in XML, apply an XSLT
    to the XML and display it in a div on the page.

    From what I can see, something like this should already do everything you want:

    $(document).ready(function() {
      // prepare sending the AJAX form (use ajaxSubmit() to actually send it)
      $('#theForm').ajaxForm({
        dataType: 'xml', 
        success:  function(responseText, statusText, xhr, $form) {
          // jQuery xslt plugin required for this:
          $.xslt({
            xml: xhr.responseXML,
            xslUrl: "xslt-test.xsl",
            target: "#ieiresponse"
          });
        },
        error: function(xhr, textStatus, errorThrown) {
          alert("Oops, there was an error: " + textStatus);
        }
      });
    });
    

    Your code is incredibly riddled with things that jQuery already does for you (like choosing the right XmlHttpRequest object depending on the browser type, and other stuff). You can and should get rid of all of this. And you should begin reading some jQuery tutorials, because even though you say differently, your code does not indicate at all that you really have.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to load fragments of XHTML markup using jQuery's $.fn.load function, but it
I have a simple html block like: <span id=replies>8</span> Using jquery I'm trying to
I am trying to find a way using jquery without cookies to display a
I am trying to get an element using JQuery's selector, but it does not
I'm trying to animate a block level element using jQuery. The page loads with
I'm trying to click on a link using jquery. There only appears to be
I'm trying to execute a asp.net webservice using jquery. When I pass only one
I'm trying to create a simple toggling sidebar using jquery, where it expands and
I'm trying to highlight just one specific row in a table using jQuery. The
I am trying to pass a dataString to to an ajax call using JQuery.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.