Ajax限制返回的项目数量


Ajax limiting amount of items returned

我正在发出这样的AJAX请求:

$("#botao_pesquisar_material").click(function(){
    $(this).attr("disabled", "disabled");
    $("#material").addClass('loading');
    $.ajax({
        url: '{{ URL::base() }}/material/lista_ajax/',
        dataType: 'json',
        cache: false,
        error: function(data)
        {
            console.log(data);
        },
        success: function(data) {
            for(x in data)
            {
                console.log(data[x]);
            }
        }
    });

我的PHP方法是可以的,因为当我通过URL访问它时,它会返回我期望的JSON,当我在localhost上调用它时,该方法工作得很好,所以它与特殊字符或其他数据无关。

当我在我的服务器上运行这个时,我有这个:

GET http://dc.portaldeideias.com.br:8080/sergios/public/material/lista_ajax/?callback=jQuery172007718208665028214_1342725644520&_=1342725649090 500 (Internal Server Error) jquery.js:4
f.support.ajax.f.ajaxTransport.send jquery.js:4
f.extend.ajax jquery.js:4
$.click.$.ajax.url
f.event.dispatch jquery.js:3
f.event.add.h.handle.i

使用console.log(data),我得到了整个JSON响应,但这里有一个真正奇怪的地方:

readyState4

responseText[{"attributes":{"pk_a030_id":78,"a030_descricao":"Camur'u00e7a"},"original":{"pk_a030_id":78,"a030_descricao":"Camur'u00e7a"},"relationships":[],"exists":true,"includes":[]}]

statusTextInternal Server Error

因此,创建了请求的值,但我收到了Internal Server Error

很抱歉将此作为答案发布,但我没有所需的权限将其添加为您问题的注释。

您是否注意到javascript日志http://localhost:8080/sergios/public/material/lista_ajax/中的URL与屏幕截图http://dc.p[...]s.com.br:8080/sergios/public/material/lista_ajax中提供的URL不同?

可能是因为lista_ajax PHP方法的两个不同版本托管在两个不同的服务器上(可能一个是远程服务器,另一个是本地服务器),这就是为什么从浏览器中看到它时工作得完美,而在使用ajax测试时却有错误的原因吗?

同样重要的是要注意,如果您正在浏览托管在远程服务器上的网站,并且ajax被配置为localhost地址,它将为您自己的机器而不是远程服务器发出请求(javascript在浏览器中运行,因此localhost转换为其自己的客户端地址)。

也许事实并非如此,但值得评论。