Selecton on jquery ajax reply

CLOMIDADVICE

New Member
I am trying to understand what is preventing jquery from parsing my XML reply.My code looks like this:\[code\]$.ajax({ url: "ajax_gateway.php?request=agentdetails&agentid=6352", dataType: "xml", success: function(xml) { console.log(xml); alert($('agentname', xml).val()); //$('input[name="agent_name"]').val($('agentname', xml).val()); } });\[/code\]I can see my intended XML logged to Chrome console. I checked headers, and my AJAX reply is sent with "Content-Type: text/xml". Unfortunately my alert is empty and if I try to do:\[code\]$(xml).("agentname").val()\[/code\]I get error message in chrome JS console saying "Uncaught SyntaxError: Unexpected token ( ".Am I missing something? I have several other function in my "ajax_gateway" and they are all working fine...Edit:My XML response:\[quote\] <?xml version="1.0"?> <response><employee><agentname>My Name</agentname><agentteam>My Team</agentteam><agentphoneid>6352</agentphoneid></employee></response>\[/quote\]While papaiatis answered my question, would anyone bother to explain why:\[code\]$(xml).("agentname").text();\[/code\]Is valid?
 
Back
Top