Hello,
strange problem, jQuery can't extract the xml data after an ajax
query... see below for the code:
my XHTML file contains a simple form:
<form method="post" name="cityForm" id="cityForm">
<input type="text" name="city" id="city" size="40" />
<input type="submit" value="Localité" id="submit" />
<img src="images/ajax-loader.gif" alt="ajax loader" id="ajax-loader" />
</form>
<div id="feedback"></div>
jquery script:
<script type="text/javascript">
$(document).ready(function(){
$("#ajax-loader").ajaxStart(function(){
$("#submit").hide();
$(this).show();
});
$("#ajax-loader").ajaxStop(function(){
$(this).hide();
$("#submit").show();
});
$("form").submit(function(){
data = $("[EMAIL PROTECTED]").val();
$.ajax({
type: "POST",
url: "find.php",
data: "localite="+data,
dataType: "xml",
success: function(xml){
result = $("count", xml).text();
$("#feedback").html("result = " +
result);
}
});
return false;
});
});
</script>
find.php (just an example to test the code):
<?php
$xml = "<result><count>5</count></result>";
header('Content-type: text/xml');
echo $xml;
?>
post:
localite=test
response:
<result><count>5</count></result>
headers:
Date: Tue, 19 Sep 2006 12:01:52 GMT
Server: Apache/1.3.33 (Darwin) PHP/5.1.4
X-Powered-By: PHP/5.1.4
Connection: close
Transfer-Encoding: chunked
Content-Type: text/xml
Any idea?
--
Roberto Ortelli
http://weblogger.ch
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/