Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2012
    Posts
    137
    Thanks
    1
    Thanked 1 Time in 1 Post

    Why isn't this simple jQuery not working?

    Other than the fact that I am dense.

    Code:
    	$(document).ready(function(){	  
    
    			var path = getModuleDataUrl();
    						
    			$.get(path, function(xmlFile)
    				{
    					$.ajax({
    						type: "GET",
    						url: path,
    						dataType: "text",
    						success: parseXml()
    					});
    			});
    			
    		 });
    
    
    function parseXml(xml)
    {
    	
    	alert("IE does not run this function " + $(xml).find('course_name').text);
    }

  • #2
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Code:
    success: parseXml()
    This is calling the function parseXml() straight-away and assigning any return value to success. You can either
    Code:
    success: parseXml // no brackets..
    
    // or, more usually,
    
    success: function (xml) { 
        alert("IE does not run this function " + $(xml).find('course_name').text);
    }
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #3
    Regular Coder
    Join Date
    Jun 2012
    Posts
    137
    Thanks
    1
    Thanked 1 Time in 1 Post
    Quote Originally Posted by AndrewGSW View Post
    Code:
    success: parseXml()
    This is calling the function parseXml() straight-away and assigning any return value to success. You can either
    Code:
    success: parseXml // no brackets..
    
    // or, more usually,
    
    success: function (xml) { 
        alert("IE does not run this function " + $(xml).find('course_name').text);
    }
    I'm sorry, I posted this just before a meeting so I rushed it. The problem is that the alert does not show the text, it shows the jQuery function code. How can I retrieve the text from the XML node?

  • #4
    Regular Coder
    Join Date
    Jun 2012
    Posts
    137
    Thanks
    1
    Thanked 1 Time in 1 Post
    Never mind. I was missing the () after text!!!!!!!!!!

    Sorry. Trying to do too many projects at once.

  • #5
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    just curious, why put a .ajax call inside of a .get ? its basically the same thing, isnt it?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •