Sto provando a passare il testo inserito al controller utilizzando una richiesta Ajax. Ma sto ottenendo athe errore "TypeError Uncaught: Impossibile impostare la proprietà 'valore' di null" quando ho provato ad eseguire il file JS ..Unchaught TypeError: Impossibile impostare il 'valore' della proprietà di null
Ecco la htmlCode:
<form action="">
<input type="text" class="searchbox1" name="search" placeholder="Search for Brand, Store or an Item..." value="text" />
<input type="button" class="searchbox_submit1" name="submit" value="text" onClick="javascript:getSearchText();">
</form>
ecco il codice JS :
function getSearchText() {
var searchText = document.getElementByName("search").value;
h_url=document.getElementById("u").value;
var theURL = h_url+'search_all/' + deptid + '/' + searchText + '/1';
$.ajax({
url : theURL,
fail: function(){
},
success : function() {
},
error:function(){
}
});
}
Please help me per risolvere questo.
possibile duplicato di [Perché jQuery o un metodo DOM come \ 'getElementById \' non trova l'elemento?] (Http://stackoverflow.com/questions/14028959/why-does-jquery-or-a- dom-method-such-as-getelementbyid-not-find-the-element) –