jQuery的1.5 AJAX发送作为POST GET数据数据、jQuery、AJAX、GET

2023-09-11 01:22:59 作者:时光偷走初心

(对不起我的英语,这是不是我的出生郎) 我有一个使用codeigniter + jQueryUI的一个项目。我想主要是因为我使用了很多AJAX调用JQuery的版本升级到1.5,并且在任何速度的改善是非常AP preciated。 所以这是我的code,至极工作正常JQuery的1.4.4版本:

(Sorry about my english, it aint my birth lang) I have a project that uses codeigniter+JqueryUI. I was thinking about upgrading JQuery version to 1.5 mainly because I am using a lot of ajax calls, and any improvement in speed is highly appreciated. So this is my code, wich works fine in JQuery version 1.4.4:

$("#nome_produto").autocomplete({
            source: function( request, response ) {
                $.ajax({
                    async:false,
                    url: "<?php echo site_url("produtos_produto/json_produtos/f") ?>",
                    dataType: "json",
                    type: "POST",
                    data: request,
                    success: function( data ) {
                        response( $.map( data, function( item ) {
                            return {
                                label: item.label,
                                value: item.label,
                                cod: item.cod
                            }
                        }));
                    },
                    beforeSend:function(){
                        $("#nome_produto").toggleClass("loading");
                    },
                    complete:function(){
                        $("#nome_produto").toggleClass("loading");
                    }
                });
            },
            minLenght:3
        });

在jQuery的1.5,我得到了一个404错误,但请求的URL是这样的: http://myurl.com/produtos_produto/json_produtos/f?callback=JQUERY_hashofnumbers ,尽管这是一个POST请求。 没有人知道为什么会发生?

In Jquery 1.5, I got a 404 error, but the url requested is this: http://myurl.com/produtos_produto/json_produtos/f?callback=JQUERY_hashofnumbers, even though this is a post request. Does anyone knows why it happens?

推荐答案

可能与此门票: HTTP ://bugs.jquery.com/ticket/8084 快速修复是:

might be related to this ticket: http://bugs.jquery.com/ticket/8084 the quick fix is:

  jQuery.ajaxSetup({ jsonp: null, jsonpCallback: null});

做Ajax调用之前

before doing ajax calls