Reputation: 1970
I am using codeigniter where i put the post backend coding under models/add_subscriber.php but the code not being hit. Any idea?
form.onsubmit = function(event) {
validate();
if (!isValid) {
revalidateOnChange();
return false;
}
var email = $("#signup_email").val();
dataString = 'email=' + email;
$.ajax(
{
type: "POST",
url: '<?php echo base_url()?>models/add_subscriber.php',
data: dataString,
success: function(response) {
alert(response);
},
error: function(xhr, textStatus, error) {
}
});
return;
};
Upvotes: 0
Views: 141
Reputation: 1218
Create a controller in the "controllers" folder... Create a file something like this:
class your_controller extends CI_Controller {
function example_function(){
// PUT HERE YOU CODE that is in the models.addsubscriber.php
}
}
In your code JS script, put this URL:
url: '<?php echo base_url()?>your_controller/example_function/'
Upvotes: 1
Reputation: 5166
try to figure out step by step,
Suggestion
if you want a URL access to a resource (such as css, js, image), use base_url()
, otherwise, site_url()
is better. source
Upvotes: 1