Ajax将转到[object%20Object] [英] Ajax going to [object%20Object]

查看:423
本文介绍了Ajax将转到[object%20Object]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想做一个简单的请求,像这样:

I'm just trying to do a simple request like this:

    $('.asd').change(
        function () {
            $.ajax({
                url: 'http://127.0.0.1/folder/index.php/controller/action/integer',
                success: function(data){}
            });
        }
    );

此代码尝试转到http://127.0.0.1/folder/index.php/controller/[object%20Object]并获取404.它从哪里提取对象?我正在使用一个简单的字符串.

This code tries to go to http://127.0.0.1/folder/index.php/controller/[object%20Object] instead and gets a 404. Where is it pulling the object from? I'm using a simple string.

推荐答案

对我来说,问题是我使用的是$.post而不是$.ajax.

For me the issue was that I was using $.post instead of $.ajax.

// fails:
$.post({
    url: "/example/" + this.id,
    // ...
});

// works:
$.ajax({
    url: "/example/" + this.id,
    // ...
});

这篇关于Ajax将转到[object%20Object]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆