Using the code from user "wildpeaks" I tried to modify it to meet my needs, but it doesn't work. My goal is to request information returned in an xml document. Parse the xml document and post the results to the appropriate input boxes. Can anyone point out where I am going wrong.
<!DOCTYPE html> <html> <head> <title>jQuery and XML</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="language" content="en" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> </head> <body> <table> <tr><td> <select name="recordList" onChange="getRecords(this);"> <option value="1">Test1</option> <option value="2">Test2</option> <option value="3">Test3</option> </select> </td></tr> <tr><td> <input type="text" name="AnswerA192" id="AnswerA192" value=""> </td></tr> <tr><td> <input type="text" name="AnswerA189" id="AnswerA189" value=""> </td></tr> </table> <script type="text/javascript"> function getRecords(what) { $.ajax({ type: 'POST', url: 'getAutoFill.php', xhrFields: { fkAutoFill: what.value }, dataType: 'xml', success: function(xml){ $('response', xml).find('dtlFill').each(function() { $("#AnswerA" + $(this).attr("fkQuestion")).value($(this).attr("colData")); }); } }); } </script> </body> </html> The XML file looks like
<?xml version="1.0" encoding="UTF-8"?> <dtlAutoFill> <dtlFill fkQuestion = "192" colData = "test1" colData2 = "test1"> <dtlFill fkQuestion = "189" colData = "test1" colData2 = "test1"> </dtlAutoFill>