में तत्वों को नहीं ढूंढ रहा है मैं jQuery के AJAX कार्यों को सीखने की कोशिश कर रहा हूं। मुझे यह काम मिल गया है, लेकिन jQuery को लौटे HTML DOM में तत्व नहीं मिलते हैं।सरल jQuery AJAX उदाहरण एचटीएमएल
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>load this</title>
</head>
<body>
<div id="wrapper">
test
</div>
</body>
</html>
यह दो अलर्ट देता है:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>runthis</title>
<script type="text/javascript" language="javascript" src="jquery-1.3.2.min.js"></script>
<script tyle="text/javascript">
$(document).ready(function(){
$('input').click(function(){
$.ajax({
type : "GET",
url : 'ajaxtest-load.html',
dataType : "html",
success: function(data) {
alert(data); // shows whole dom
alert($(data).find('#wrapper').html()); // returns null
},
error : function() {
alert("Sorry, The requested property could not be found.");
}
});
});
});
</script
</head>
<body>
<input type="button" value="load" />
</body>
</html>
कौन सा "ajaxtest-load.html" इस पृष्ठ को लोड करता है: jQuery के रूप में एक ही फ़ोल्डर में, इस पेज को चलाते हैं। एक दिखा रहा है कि डोम लोड किया गया था, लेकिन दूसरे #Wrapper के बजाय NULL दिखाता है। मैं क्या गलत कर रहा हूं?
संपादित करें: मैं "AJAXtest-load.html" लोड कर रहा हूं जिसमें पूरे शीर्षलेख शामिल हैं, जिसमें jquery दोबारा शामिल है। क्या यह मुद्दा है? $.load documentation से
$('#testDiv').load('ajaxtest-load.html #wrapper', function(resp) {
alert(resp);
});
:
शायद शीर्ष कोड को साफ़ करें और 'ajaxtest-load.html' पर HTML जैसा दिखता है पोस्ट करें – ScottE
दूसरा HTML ब्लॉक ajaxtest-load.html है। विवरण संपादित किया गया। उसके लिए माफ़ करना। – user110218