I have a form and I want to add AJAX functionality to this form.
Architecture: MVC
I have a basic form like this:
<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 this 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 process class which is there in controller and have this code within
class process {
function __construct() {
echo 'Constructor';
}
}
But Doing all this gives me Error message through AJAX. Why is this happening? Is there any other way of doing this. Here under is snapshot:

Here under is my .HTACCESS rule
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
So when I am directly navigation to my process class its working. But not with AJAX. What would be the possible reason for this?? Here under is the screenshot:
