I have a form, and I want to add AJAX functionality to this form.
Architecture: MVC
I have a basic form:
<form id="customForm" method="post"> <input type="text" id="name" name="zone_name" value="" class="input-block-level" /> <button type="submit" id="save" >Save</button> </form>
I have JS on my MVC-View :
$('#save').click(function() { var name = $('#name').val(); $.ajax ({ type: 'POST', url: 'http://localhost/myApp/process', data: "{name:"+name+"}", success: function (result) { alert(result); }, error: function () { alert('fail'); } }); });
I have a class process , which is in the controller and has this code inside
class process {
function __construct () {
echo 'Constructor';
}
}
But all this gives me an Error message via AJAX. Why is this happening? Is there any other way to do this. Below is a snapshot:

Here is my .HTACCESS rule
RewriteCond% {REQUEST_FILENAME}! -D
RewriteCond% {REQUEST_FILENAME}! -F
RewriteCond% {REQUEST_FILENAME}! -L
RewriteRule ^ (. +) $ Index.php? Url = $ 1 [QSA, L]
Therefore, when I am directly in my process class, it works. But not with AJAX. What would be a possible reason for this? Below is a screenshot:

source share