jsuissa
jsuissa

Reputation: 1762

Jquery ajax function not returning success or failure suddenly

The function below has stopped working and I'm unable to track down the cause. It's not generating a success or failure message and nothing appears on the console.

Everything before the ajax portion of the function works fine. In PHP I put an echo on the controller and nothing is returned. Similar functions with near identical ajax calls are working fine in the same page.

Any advice on this would be greatly appreciated.

$('#template_id').change(function() {       

var src = "http://localhost/"+"templates/"+$('#template_id').val()+"/thumb.png";

    $('#template_image').attr("src", src);
    $.ajax({
        type : 'POST',
        url : 'http://localhost/index.php/resume/change_template',
        data: {
            resume_id : '297',                              
            template_id: $('#template_id').val()
        },
        success : function(msg){
        },
        error: function(){
            alert('failure');
        }
    }); 

}); 

Upvotes: 2

Views: 1761

Answers (2)

joni_demon
joni_demon

Reputation: 666

I think you dont miss anything there,try to use a firebug to see what is happening to ajax request

By the way you should also check if your ajax is being called

Upvotes: 1

otakustay
otakustay

Reputation: 12395

It seems you put your success and error callbacks in data property, put them out:

$.ajax({
    type : 'POST',
    url : 'http://localhost/index.php/resume/change_template',
    data: {
        resume_id : '297',                              
        template_id: $('#template_id').val()
    },
    success : function(msg) {
    },
    error: function() {
        alert('failure');
    }
); 

Upvotes: 0

Related Questions