jquery - javascript function containing ajax do not work after submit but work with button click event -


it strange. have function ajax works great:

function searchproduct(){ var barcode=$.trim($('#barcode1').val()); $.ajax({         type: 'get',         url: 'http://.............',         data:{              action: "search",              var: barcode,              },         cache: false,         datatype: 'json',         success: function(output){ 

when call function form submit event, way, error function of ajax.

<form id="searchbox" name="searchbox" onsubmit="searchproduct()"> 

but if call function button click event works , success()

<span  class="tab-label" onclick="searchproduct()">scan</span> 

what think this?

form submit send httprequest web server, wonder why want send ajax request along that.

onclick simple event can use trigger ajax request, not send other httprequest server.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -