简体   繁体   English

未捕获的类型错误:JavaScript

[英]Uncaught Type Error:JavaScript

$(document).ready(function(){
    $('.completecompanyDetails').click(function(){
        var orgname = $("#companyName").val();
                var jsonData = {};
        jsonData.orgName = orgname;
        $.ajax({
            url: url,
            data:JSON.stringify(jsonData),
            type:"text",
            method:"POST",
            contentType:'application/json',
            success: function(data){
                window.location.href="/config";
                return true;
            },
            error: function () {
                alert("Error!");
                return true;
            }
        });
    });
});

I'm getting the following error in the 8th line: 我在第8行遇到以下错误:

Uncaught TypeError: Accessing selectionDirection on an input element that cannot have a selection.

type is used to define get or post method. type用于定义get或post方法。 type :'text' is not a valid option. type :'text'是无效的选项。 What you are setting value on method that will come under type option. 您要在类型选项下的方法上设置值。

If you want to set data type in which you want to recieve response use dataType key. 如果要设置要接收响应的数据类型,请使用dataType键。 Even in dataType key only xml, json, script, or html are allowed. 即使在dataType键中,也仅允许使用xml,json,脚本或html。

See jquery ajax documentation in http://api.jquery.com/jQuery.ajax/ 请参阅http://api.jquery.com/jQuery.ajax/中的 jquery ajax文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM