简体   繁体   中英

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:

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

type is used to define get or post method. type :'text' is not a valid option. 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. Even in dataType key only xml, json, script, or html are allowed.

See jquery ajax documentation in http://api.jquery.com/jQuery.ajax/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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