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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2012
    Posts
    137
    Thanks
    1
    Thanked 1 Time in 1 Post

    This works on IE but not FF

    Hello,

    The code below works fine in IE but the text does not show up in FF. I am thinking it is an XML problem (not sure I have mastered the whole passing XML objects correctly).

    This line '$("#lnx_what_to_do").html(commandArr[currCommand].find('whatToDo').text());' sets a textfield with text from the XMLfile. This is what is not working in FF.

    Any insight as to why this is not working?

    Code:
    <script>
    
    var path = "linux_sim/data/linux_sim.xml";
    var numCommands = 0;
    var commandArr = [];
    var currCommand = 0;
    
    $(document).ready(function(){
    	$.get(path, function(xml){
    		$.ajax({
    			type: "GET",
    			url: "linux_sim/data/linux_sim.xml",
    			dataType: "text",
    			success: parseLinuxSimXML
    		});			
    	});
    });
    
    function parseLinuxSimXML(xml)
    {
    	numCommands = $(xml).find('command').length;
    
    	//***** Store each command block seperately in the command array. ********/
    	$(xml).find('command').each(function(){
    		commandArr.push($(this));
    	});
    	
    	if(currCommand <= numCommands)
    	{
    		//****** inserts question *****/
    		alert(xml);
    		$("#lnx_what_to_do").html(commandArr[currCommand].find('whatToDo').text());
    		alert(/*commandArr[currCommand]*//*.find('whatToDo').text()*/xml.find('farewell'));
    	}
    }
    
    	
    $("#lnx_input").focus();
    
    $("#linux_frame").click(function(){
    	$("#lnx_input").focus();
    });
    
    </script>
    Here is the entore xml file:
    Code:
    <requiredRootNode>
    	<directions>Follow the directions in the caption window below. This caption window will also give explanations as you progress. To start over simply click the 'Rest' button..</directions>
    	
    
    
    	<correct>That's correct.</correct>
    	<incorrect>Sorry, please try again.</incorrect>
    	
    
    	
    	<farewell>Congratulations, you have completed this simulation. You can click the 'RESET' button to go through the commands again or you may choose to continue on in the course.</farewell>
    	
    
    
    	
    	<commandArray>
    		
    		<command cPrompt="$">
    			<whatToDo>List the contents of the current directory.</whatToDo>
    			<commText>ls</commText>
    			<output>pics	music	documents</output>
    			<outPutInfo>Good. With this information a user can navigate to another directory, edit a specific file, etc.</outPutInfo>
    		</command>
    		
    		<command cPrompt="$">
    			<whatToDo>List the contents of the 'documents' directory.</whatToDo>
    			<commText>ls documents</commText>
    			<output>info.doc    extra.txt</output>
    			<outPutInfo>Very good. This illustrates the fact that a user can display the contents of directories that they are not currently in.</outPutInfo>
    		</command>
    		
    		<command cPrompt="$">
    			<whatToDo>List the contents of the 'documents' directory again.</whatToDo>
    			<commText>ls documents</commText>
    			<output>info.doc    extra.txt</output>
    			<outPutInfo>Great. Again, a user can display the contents of directories that they are not currently in.</outPutInfo>
    		</command>
    		
    		<command cPrompt="$">
    			<whatToDo>Change the current working directory to the 'documents' directory.</whatToDo>
    			<commText>cd documents</commText>
    			<output>/home/user/documents</output>
    			<outPutInfo>Very good. The 'cd' command changed the working directory to the 'documents' directory. </outPutInfo>
    		</command>
    		
    		<command cPrompt="$">
    			<whatToDo>Verify the shell is the 'documents' directory.</whatToDo>
    			<commText>pwd</commText>
    			<output>/home/user/documents</output>
    			<outPutInfo>Excellent. The 'pwd' command prints the path to the current working directory. </outPutInfo>
    		</command>
    		
    		<command cPrompt="$">
    			<whatToDo>Remove the file extra.txt.</whatToDo>
    			<commText>rm extra.txt</commText>
    			<output></output>
    			<outPutInfo>Good job. The 'rm' command removes files from the filesystem. </outPutInfo>
    		</command>
    		
    		<command cPrompt="$">
    			<whatToDo>Now verify that the 'extra.txt' file was indeed removed.</whatToDo>
    			<commText>ls</commText>
    			<output>info.doc</output>
    			<outPutInfo>Great. Here we can see that the 'extra.txt' file is gone. </outPutInfo>
    		</command>
    		
    		
    	</commandArray>
    
    </requiredRootNode>

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    I'm a little confused. From what I'm seeing, you use jQuery.get() to get the file, but within the .get() you use .ajax() to do exactly the same thing? A .get() within a .get() of the same file?

    I've had minor issues with functions being loaded _after_ the $(document).ready(). Try putting everything outside of the doc.ready() before it.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #3
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,355
    Thanks
    11
    Thanked 558 Times in 551 Posts
    And on top of it: You are specifying "text" as dataType, but then you are expecting to get back an XML document... why not specify dataType: 'xml' then?


  •  

    Posting Permissions

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