मैं एक जॉकरी के चयनकर्ता को खोजने की कोशिश कर रहा हूंअजाक्स कॉल करने के बाद "सफलता" में स्वतः पूर्ण। "सफलता" में मैं $ (यह) $ ("आइटमडेस इनपुट") की तलाश में हूं लेकिन यह नहीं है। मुझे उस बिंदु पर चयनकर्ता कैसे मिलेगा?
$(".itemDescInput").autocomplete({
source: "invoices/invoice_items.php",
select: function(event, ui) {
var $it_desc = ui.item.value;
$.ajax({
type: "POST",
url: "invoices/invoice_items_prices.php",
data: "it_desc="+$it_desc,
success: function(result){
if(result != "") {
$(this).find("input .itemCostEach").val(result);
}
}
});
}
});
उत्तर:
जवाब के लिए 2 № 1अंदर success()
, this
अपने चयनकर्ता को संदर्भित नहीं करता है, लेकिन आपके लिए AJAX सेटिंग्स। आप क्या बदल सकते हैं this
सेटिंग से इंगित करता है प्रसंग आपके में ajax()
कहते हैं। देखें प्रलेखन.
उदाहरण के लिए:
$.ajax({
context: this, // You could pass "this" in directly if you wanted :)
success: function(result) {
// Refer to "this" in the way you expect
}
});