脚本ajax与他人冲突

时间:2018-04-17 03:13:03

标签: javascript jquery ajax

我的脚本与其他人发生冲突,当我使用行.noConflict ();时它工作正常,但另一个脚本停止工作。如果我删除行.noConflict ();,脚本将停止工作,另一个脚本将恢复正常。它能是什么? 在身体打开后我使用https://code.jquery.com/jquery-3.2.1.slim.min.js

$(function() {
    $("#contact .button").click(function() {
        var name = $("#form_name").val();
        var email = $("#form_email").val();
        var text = $("#msg_text").val();
        var dataString = 'name='+ name + '&email=' + email + '&text=' + text;

        $.ajax({
            type: "POST",
            url: "email_demo.php",
            data: dataString,
            success: function(){
                $('#success').fadeIn(1000);
            }
        });

        return false;
    });
});

我试试这个但不能正常工作

            a$.noConflict();
            a$(function() {
                a$("#contact .button").click(function() {
                    var name = $("#form_name").val();
                    var email = $("#form_email").val();
                    var text = $("#msg_text").val();
                    var dataString = 'name='+ name + '&email=' + email + '&text=' + text;

                    a$.ajax({
                        type: "POST",
                        url: "email_demo.php",
                        data: dataString,
                        success: function(){
                            a$('#success').fadeIn(1000);
                        }
                    });

                    return false;
                });
            });

我的表格:

<form name="solicitarDemo" method="post" class="" id="contact">  
 <section id="left">
   <label for="form_name">Name</label>
     <input name="form_name" id="form_name" type="text" >

   <label for="form_email">Email</label>
     <input name="form_email" id="form_email" type="email" >
 </section>

 <section id="right">
   <label for="form_msg">Message</label>
     <textarea name="form_msg" id="form_msg"></textarea>
   <input id="submit" class="button" name="submit" type="submit" value="Send">
 </section>

</form>

<div id="success" style="width:60%; display: none;">
Solicitação enviada, aguarde nosso contato em breve.
</div>

脚本:

<body>
        <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>

        <!--  conflict with this script-->
        <script src="sliderPro/js/jquery.sliderPro.min.js"></script>

0 个答案:

没有答案