Solved

Jquery xml

Posted on 2013-01-15
3
237 Views
Last Modified: 2013-01-22
The following code ceased to work today.

$(data).find("ListItem").each(function()
                              {
                                    h += "<option value='" +  $(this).attr("Code")  +   "'>"  +  $(this).attr("Code") +  " " + $(this).attr("Desc") + "</option>"
                                    
                              });

It errs on the $(this).attr("Code")
where ListItem is an xml node with Code and Desc verified as attributes in every node.

I am using the http://code.jquery.com/jquery-latest.min.js
so I am asking if this should be suspect, something deprecated?
0
Comment
Question by:KeithMcElroy
  • 2
3 Comments
 

Author Comment

by:KeithMcElroy
ID: 38781094
Here is a broader sample of the code

      $(document).ready(function(){
                   $.ajax({
                        type: "POST",
                        url: "../../isapi/btwebrqb.dll",
                        data: xmlContent,
                        contentType: "text/xml",
                        dataType: "xml",
                        success: function(data,extStatus,jqXHR){
                              var h = "<option value=''></option>"
                              $(data).find("ListItem").each(function()
                              {
                                    h += "<option value='" +  $(this).attr("Code")  +   "'>"  +  $(this).attr("Code") +  " " + $(this).attr("Desc") + "</option>"
                                    
                              });

                              $("#vacancyi_departmt_1").html(h);  //make blank per spec
                              $("#position_newrdept_1").html(h);
                        },
                        complete: function(){
                        
                              sortListByText("#vacancyi_departmt_1");   //GOTO:  load-picklists.js:16
                              sortListByText("#position_newrdept_1");   //GOTO:  load-picklists.js:16

                                    
                        },
                        error: function(request,status,error){
                              alert("Error occurred Ref: load-picklists.js loadDeptList Line 175 Error:" + request.responseText);                                                      }
                  });
            });
0
 

Author Comment

by:KeithMcElroy
ID: 38781202
More info,  I swtiched bewteen the following

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript"></script>

First line fails, second line succeeeds.
So, why?  is the xml attr deprecated?
This broke today, was working on Saturday.
0
 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 500 total points
ID: 38781853
I believe it is working,
http://jsfiddle.net/3a6rG/6/
unless the XML is malformed (?)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question