Reputation: 55
It looks like "save_masmoh_user is not a function" is a very common problem with JavaScript, yet after looking through quite a few threads I still cannot understand what is causing it in my case.
I have a custom object, defined as:
function save_masmoh_user() {
var save_masmoh = $("#save_masmoh").serialize();
var ft_user_id = $('#ft_user_id').val();
$.ajax({
url: "<?php echo base_url(); ?>myaccount/saveMasmohToUser/",
type: "POST",
data: {
save_masmoh: save_masmoh,
ft_user_id: ft_user_id
},
dataType: "json",
success: function (data) {
if (data.msg == "save") {
alert("Done");
} else {
alert("Error");
}
}
});
}
Upvotes: 0
Views: 189
Reputation: 207501
It means that your function is not in the scope that you are calling it in. I am guessing you are calling it as a global and you have it defined in an onready block. Hard to tell with the lack of code.
You should probably be using unobtrusive code so call it with
$("#yourId").on("click", save_masmoh_user);
Upvotes: 1