Having gone through all the exisiting questions, I could not find a solution to the problem I was facing.
I have a Codeigniter application, which on one of it's views has a form which makes a AJAX call to submit data.
I have the Jquery code working for two AJAX calls but for one of the calls, from what I monitor in the header returns a resource not found error for the controller I call via POST. If I load the same resource directly, the browser loads the URL.
Here's my code
$(document).ready(function()
{
$("#submit_tag").click(function(){
$("#current_tags").fadeOut("fast");
tag = $("#new_tag").val();
$.ajax({
type: "POST",
data: "data="+tag,
//This returns a resource not found error
url: "<?php echo site_url('user/updatetag/');?>/",
success: function(msg)
{
$("#current_tags").remove();
$("#current_tags").fadeIn("fast");
$("#current_tags").html(msg);
}
});
});
$("a.single_tag").click(function(){
the_id = $(this).attr('id');
$.ajax({
type: "POST",
data: "data="+the_id,
//This URL works url: "<?php echo site_url('user/deletetag/');?>/",
success: function(msg)
{
$("#current_tags").fadeIn("slow");
$("#current_tags").html(msg);
}
});
});
});
Thanks for your time
what is #new_tag, is it input field/text area/select/similar
or usual html tag
like div?
if its about input/text area/select/similar
, then your AJAX/JS is OK. May be problem in CI code.
if its usual html tag
, then you should get the value of that tag using .html()
-
tag = $("#new_tag").html();
#new_tag
is a id of a textfield from which I am reading a value from to be inserted into the database.
All the CI code does is echo "Saved";
from what I see on Firebug, it says that it failed to load the resource.
EDIT :
I resolved the issue, but adding a action to POST="(Code Igniter URL)"
to the form tag which was previously missing.