Javascript ajax调用不能传递参数,只能在某些浏览器上使用

Javascript ajax调用不能传递参数,只能在某些浏览器上使用,javascript,jquery,ruby-on-rails,ajax,Javascript,Jquery,Ruby On Rails,Ajax,我对这个应该进行ajax调用的函数有问题: function updateCountriesPrice(){ var countryFrom = select_country_from.options[select_country_from.selectedIndex].value; var countriesTo = JSON.parse("[" + $('#countriesToUpdate').val() + "]"); var array

我对这个应该进行ajax调用的函数有问题:

function updateCountriesPrice(){
        var countryFrom = select_country_from.options[select_country_from.selectedIndex].value;

        var countriesTo = JSON.parse("[" + $('#countriesToUpdate').val() + "]");
        var arrayProductCode = [];
            arrayProductCode=localStorage.list_id.replace(/ /g,'');
        var data = {'products_list': arrayProductCode,
                        'country_from': countryFrom,
                        'countries_to': countriesTo};
        console.log(data);
        $.ajax({
            url: './products_actions_prices',  //Server script to process data
            type: 'POST',
            xhr: function() {  // Custom XMLHttpRequest
                var myXhr = $.ajaxSettings.xhr();
                if(myXhr.upload){ // Check if upload property exists
                    myXhr.upload.addEventListener('progress',progressHandlingFunction, false); // For handling the progress of the upload
                }
                return myXhr;
            },
            //Ajax events

            success: function(data, textStatus, jqXHR){
                $('#div_action_selected').html('').hide();
                jQuery('#wrapper').append('<div class="flash success" >'+jqXHR.responseJSON.text+'</div>');
                setTimeout(function(){$('.flash').slideUp(1000);},3000);
                $('#div_action_selected').html('').hide();
                jQuery.each(jQuery('.check_box'),function(key,value){
                    if(jQuery('#select_all').is(':checked')){
                        $(this).prop('checked', false);
                    }
                });
                $('#select_all').prop('checked', false);//$('#select_actions').hide();
                $('#select_all_products_div').hide();
                localStorage.clear();localStorage.setItem('list_id','');
                setInterval(location.reload(),2500);
                hideDivAction();

            },
            error: function (jqXHR, textStatus, errorThrown){
                $('#div_action_selected').html('<div id=\"errorExplanation\" class=\"errorExplanation\" data-hook=\"\">'
                    +' <h2>One error prohibited this action:</h2>'
                    +' <p>There were problems with the call.</p>'
                    +' </div>');
                    setTimeout(function(){$('#div_action_selected').slideUp(1000);},3000);
                    //$('#select_actions').attr('value','');
            },
            // Form data
            data: data,
            //Options to tell jQuery not to process data or worry about content-type.
            cache: false,
            contentType: false,
            processData: false
        });


    }
使用chrome可以进行调用并看到成功的结果,但是我的params变量不包含我使用ajax传递的数据。 当我打电话时 控制台日志数据; 我可以完全按照我想要的方式查看数据,但它们没有到达我的rails控制器

使用firefox或ajax启动

谢谢。

您缺少数据类型

根据,

数据类型默认值:智能猜测xml、json、脚本或html 类型:字符串 期望从服务器返回的数据类型。如果未指定任何值,jQuery将根据响应的MIME类型尝试推断它。XML MIME类型将生成XML,在1.4中,JSON将生成JavaScript对象,在1.4中,脚本将执行脚本,其他任何内容都将作为字符串返回。作为成功回调的第一个参数传递的可用类型和结果如下:


没有参数变量。如果您谈论的是包含产品列表等的数据对象,那么您还没有将其添加到Ajax请求中。为什么您说我没有将其添加到Ajax请求中?我遵循了很多指南,发现这个语法你没有在Ajax中发送任何数据,比如$.Ajax{data:dataHe意思是你没有在Ajax请求中发送数据。$.ajaxurl:url,data:{any:data}嘿,伙计们,@TWONEKSONE正在发送数据,在查询的最后…在我看来,问题是processData。如果我传递2个字符串和1个数组,我应该使用哪种数据类型。我认为默认值应该有效。你应该传递的数据类型取决于你的数据。根据你的问题,我不知道你使用的是哪种数据类型。你在尝试吗要将XML/JSON发送到服务器?