2

I'm currently getting the error Object #<Object> has no method 'toUpperCase' before the POST request is made, so I would like and appreciate a lot your help! Thanks

function ajaxeo(url, data, method){
    $.ajax({
        url: url,
        type: method,
        data: data,
        success: function(response){
            alert(response);
        }
    });
}

function cambio(ID, newValue){
ajaxeo("includes/php/ajax/changeProvider.php?oldID="+ID, "post", {"newVal": newValue});
}

var editable = $('div[contentEditable][dataAjax]');
for (var i=0, len = editable.length; i<len; i++){
    editable[i].setAttribute('data-orig',editable[i].innerHTML);
    editable[i].onblur = function(){
        if (this.innerHTML == $(this).attr('data-orig')) {
            // no change
        }
        else {
            // change has happened, store new value
            $(this).attr('data-orig', $(this).html())
            cambio($(this).attr('dataId'), $(this).html());
        }
    };
}

You passed your parameters wrong

ajaxeo("includes/php/ajax/changeProvider.php?oldID="+ID, "post", {"newVal": newValue});

should be

ajaxeo("includes/php/ajax/changeProvider.php?oldID="+ID, {"newVal": newValue}, "post");

The error is probably jQuery trying to make sure the method is in uppercase

4

1 回答 1

1

您错误地传递了参数

ajaxeo("includes/php/ajax/changeProvider.php?oldID="+ID, "post", {"newVal": newValue});

应该

ajaxeo("includes/php/ajax/changeProvider.php?oldID="+ID, {"newVal": newValue}, "post");

错误可能是 jQuery 试图确保方法是大写的

于 2013-01-05T05:40:58.530 回答