Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
110
rated 0 times [  113] [ 3]  / answers: 1 / hits: 61191  / 10 Years ago, wed, april 9, 2014, 12:00:00

I have this code



<a data-remote=true data-box_no=1 class=find_or_add_horse href=#>Find/Add Horse</a>


And I do ajax call when I click one the link



$(document).on('click', '.find_or_add_horse', function () {
var search_term = $(this).parents('.sub-middle-column').find('.search_horse');
var box_no = $(this).data('box_no');


$.ajax({
url: /startup_wizard/find_horse,
dataType: 'script',
type: 'GET',
data: { box_no: box_no, search_term: search_term}
});
return false;


});


But when I click on the link I get this error TypeError: 'stepUp' called on an object that does not implement interface HTMLInputElement when I remove this code from ajax call



data: { box_no: box_no, search_term: search_term}


my code just work fine. Why this is happening and how to fix this? How can I send the data?


More From » jquery

 Answers
8

If search_term is an input field you might want to get its value.



var search_term = $(this).parents('.sub-middle-column').find('.search_horse').val();


Right now you are referencing a jQuery Object containing a HTMLDom-Element but I think what you want is the string inside the search input element.


[#71544] Monday, April 7, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jananauticat

Total Points: 1
Total Questions: 105
Total Answers: 95

Location: Azerbaijan
Member since Fri, May 12, 2023
1 Year ago
;