Hi all, greets for the useful group about jQuery.
I'm in needing of a little help, because I'm stuck at an endless
point.
I've created a little search script using jquery, that asks a page for
an xml (based on the query) and prints out some params on the html
parent page.
Here's the code:

::: searchPage.htm
----------------------------------------------------------------------------------------------

<html>
<head>
        <title>Prova ricerca</title>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript">
                $(function() {
                        $('#submitButton').click(function() {
                                var query = $("#query").val();
                                $.ajax({
                                        type: 'POST',
                                        url: 'test.php',
                                        data: 'q=' + query + '&p=1&rpp=10',
                                        dataType: 'xml',
                                        error: function(request, type) {
                                                
$('#filling').html(request.responseText);
                                                alert(type);
                                        },
                                        success: function(xml) {
                                                
$(xml).find('label').each(function() {
                                                        var prova = 
$(this).find('name').text();
                                                        
$('#filling').append(prova + "<br>");
                                                });
                                        }
                                });
                        });
                });
        </script>
</head>
<body>
<input type="text" id="query">
<input type="submit" value="cerca" id="submitButton">
<div id="filling"></div>
</body>
</html>

----------------------------------------------------------------------------------------------

Here's an example of the XML output of test.php

::: test.php XML output
----------------------------------------------------------------------------------------------

<?xml version="1.0" encoding="iso-8859-1"?>
<root>
 <labels>
   <label>
     <name>EzraPound</name>
     <address>
       <street>45UsuraPlace</street>
       <city>Hailey</city>
       <province>ID</province>
     </address>
   </label>
 </labels>
</root>

----------------------------------------------------------------------------------------------

The problem is that the javascript never reaches the success function
and stays stuck @ the function error, printing out the XML response
correctly and alerting me with the "parsererror" message ( the type
variable of error: function(request, type) )
Where's the problem? What do i have to do?
Thanks in advance!

Reply via email to