I trying to upgrade a website to make it easily replicable and more database driven.
My forms use PHP / AJAX to submit to response.php within the same directory.
E.G domain.com/client1/login.php this would use JS in /js/common.js
common.js will take the variables from the form name and use domain.com/client1/response.php?action=login
The issue I am having is that despite login.php and response.php both being in client1/, the JS is trying to locate response.php at domain.com/response.php
Is there a way of forcing the JS to use the local directory or taking my php url: ‘$isteURL/response.php’,
Any help would be gratefully appreciate, racking my head here.
$siteURL is defined in the header.php above the JS file
function submitForm3() {
var data = $("#reset-form").serialize();
$.ajax({
type : 'POST',
url : '<?php echo $siteURL; ?>/response.php?action=reset',
data : data,
beforeSend: function(){
$("#error").fadeOut();
$("#reset_button").html('<span class="glyphicon glyphicon-transfer"></span> sending ...');
},
success : function(response){
if($.trim(response) === "1"){
console.log('dddd');
$("#reset-submit").html('Email sent ...');
setTimeout(' window.location.href = "index.php?resetStatus=1"; ',2000);
} else {
$("#error").fadeIn(1000, function(){
$("#error").html(response).show();
});
}
}
});
return false;
}