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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    jQuery and XML problem

    Well i dont know why my code doesnt work!


    Code:
    $(document).ready(function(){
    	$.ajax({
    		type: "GET",
    		url: "subjectdata.xml",
    		dataType: "xml",
    		success: function(xml) {
    			$(xml).find('narucitelj').each(function(){
    				var vrsta = $(this).find('vrsta').text();
    				$('#vrsta').html("vrsta");
    			});
    			
    		};
    		
    	});
    
    });

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,355
    Thanks
    11
    Thanked 558 Times in 551 Posts
    Let me guess: You only see the string "vrsta" in the element with id="vrsta" ?

    That's because you put the literal string "vrsta" there instead of the content of the variable "vrsta"

    Try this
    Code:
    $(document).ready(function(){
    	$.ajax({
    		type: "GET",
    		url: "subjectdata.xml",
    		dataType: "xml",
    		success: function(xml) {
    			$(xml).find('narucitelj').each(function(){
    				var vrsta = $(this).find('vrsta').text();
    				$('#vrsta').html(vrsta);
    			});
    			
    		};
    		
    	});
    
    });


  •  

    Posting Permissions

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