我需要从localhost调用一个url,但我得到$ .ajax不是函数错误

时间:2017-01-29 15:41:32

标签: javascript jquery ajax

目前我在localhost上测试所有内容,但在我的实时版本中,我将调用在线(http)网址。

我已经包含了最新的jQuery

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

现在我的javascript的主要部分

<script type="text/javascript">
            $(document).ready(function () {


                $('#theBarcodeA').keyup(function (e) {
                    barcodeA = $(this);
                    // if Enter key was pressed, send the barcode to backend 
                    if ((e.keyCode == 13) && (barcodeA.val().length > 2)) {

                        $('#theBarcodeB').focus();
                        //clean the message/status
                        document.querySelector('#status').innerHTML = '';

                    }

                });
                $('#theBarcodeB').keyup(function (e) {
                    barcodeB = $(this);
                    // if Enter key was pressed, send the barcode to backend 
                    if ((e.keyCode == 13) && (barcodeB.val().length > 2)) {

                        document.querySelector('#status').innerHTML = barcodeA.val()+' '+barcodeB.val();//just testing
                        var codeA = barcodeA.val();
                        var codeB = barcodeB.val();

                        $.ajax({
                            type: "POST",
                            url: "http://localhost/testdomain.com/scannerconnector/connectBars.php",
                            data: 'barcodeA=' + codeA + '&barcodeB=' + codeB,
                            success: function (data) {
    console.log(data);
    console.log(status);
                                $("#status").html(data);
                                // document.querySelector('#status').innerHTML = data;
                            }
                        });


                    }

                });


            });

但我得到“$ .ajax不是函数”错误消息

0 个答案:

没有答案