jquery, xml,

I have below jquery reading xml,
but not sure why below alert statement is not working.

Alert("HI " + bondState);


function fnGetBondAmount() {
    $.ajax({
        url: "http://localhost:5489/BondList.xml",
        success: function (xml) {
            parseSelectXMLBondAmountList(xml, "bondAmount", "CA", "Contractor")
        },
        error: function (xhr, ajaxOptions, thrownError) {
            alert("Status: " + xhr.status);
            alert("Error: " + thrownError);
        }
    });
}
function parseSelectXMLBondAmountList(xml, selectid,bondState,bondName) {
    var selecthtml = '', selectBondName, selectedbondAmountType;
    $('#' + selectid).prop("disabled", false);
    $(xml).find(xmlnode).each(function () {

        if (bondState == $(this).find('GeneralInformation').find('State').text()) {
            alert("HI " + bondState);             
      }
    });
}

<?xml version="1.0" encoding="utf-8"?>
<Surety>
  <SuretyLine>
    <Commercial>
      <Bond>
        <GeneralInformation UI="BondInfo">
		<State ID="bondState" PrefillValue="Yes">CA</State>
		<Product>A</Product>
	</GeneralInformation>
        <GeneralInformation UI="BondInfo">
		<State ID="bondState" PrefillValue="Yes">CA</State>
		<Product>B</Product>
	</GeneralInformation>
	<GeneralInformation UI="BondInfo">
		<State ID="bondState" PrefillValue="Yes">TX</State>
		<Product>C</Product>
	</GeneralInformation>
      </Bond>
    </Commercial>
  </SuretyLine>
</Surety>

Open in new window

LVL 1
ITsolutionWizardAsked:
Who is Participating?
 
Julian HansenConnect With a Mentor Commented:
It is not clear what you are asking as Ryan has pointed out xmlnode has not been defined. Looking at your data I am guessing you want something like this
function parseSelectXMLBondAmountList(xml, selectid,bondState,bondName) {
    var selecthtml = '', selectBondName, selectedbondAmountType;
// Not defined in your sample so I have commented it out
//    $('#' + selectid).prop("disabled", false);
   // Replaced xmlnode with GeneralInformation as that is the node
   // where bond information is defined
    $(xml).find('GeneralInformation').each(function (i,e) {
        if (bondState == $(this).find('State').text()) {
            alert("HI " + bondState);             
      }
    });
}

Open in new window

0
 
ITsolutionWizardAuthor Commented:
Any helps?
0
 
Ryan ChongCommented:
Any helps?

error message: ReferenceError: xmlnode is not defined

you got to define xmlnode in function: parseSelectXMLBondAmountList

and your requirement is not clear.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.