Trying to submit a form using ajax, but it’s just not working
$('#Submit').on('click',function(){
$.ajax({
type: 'get',
url: 'ItemProcessor.php',
data: $('#input_form').serialize(),
success: function(response){
alert(response)
},
error: function(){
alert('error')
}
})
event.preventDefault()
})
<form id="input_form">
<input type="image" src="AddToCart.png" id="Submit"/>
<input type="number" id = "stupid" name = "Amount" min="1">
<input type="text" name = "ID" value="Ice Cream" readonly style="display: none;">
<input type="text" name = "Cost" value="2" readonly style="display: none;">
<input type="text" name = "Kom" value="1" readonly style="display: none;">
<input type="text" name = "EAN" value="4551212511" readonly style="display: none;">
<input type="text" name = "Type" value="Food/Sweets" readonly style="display: none;">
</form>
I want the javascript code to send the form to ItemProcessor.php, but when I click the form, the form just acts like normal and the function doesn’t get called. neither success nor error get called, so I’m assuming the function isn’t activating but I have no idea why. This is the only form on the page