Javascript ajax未调用..甚至警报也不起作用

Javascript ajax未调用..甚至警报也不起作用,javascript,html,ajax,Javascript,Html,Ajax,我在html页面中编写此代码是为了在该页面中隐藏一个id。警报也不起作用。未调用方法 *<script> alert("yo"); $(function checkUsertype(email_id) { alert("yup") var usertype = $("#txtusertype").val(); $.ajax({ alert("hide") url:

我在html页面中编写此代码是为了在该页面中隐藏一个id。警报也不起作用。未调用方法

*<script>    
alert("yo");    
$(function checkUsertype(email_id)
    {    
    alert("yup")   
    var usertype   = $("#txtusertype").val();    
    $.ajax({    
        alert("hide")    
        url: 'rest/search/userType?email_id='+email_id,    
        type : "GET",
        datatype : 'json',
        cache : false,
        success : function(data) 
           {
               if(usertype=='webuser')
               {
               $("#themer").hide();
               }
                },
               error : function(xhr, data, statusText,errorThrown) 
               {
           }
           });
})
alert("yo");
<script/>*
*
警惕(“yo”);
$(函数checkUsertype(电子邮件id)
{    
警惕(“是”)
var usertype=$(“#txtusertype”).val();
$.ajax({
警报(“隐藏”)
url:'rest/search/userType?email_id='+email_id,
键入:“获取”,
数据类型:“json”,
cache:false,
成功:功能(数据)
{
if(usertype=='webuser')
{
$(“#themer”).hide();
}
},
错误:函数(xhr、数据、状态文本、错误抛出)
{
}
});
})
警惕(“yo”);
*
这就是问题所在

$.ajax({    
    alert("hide")
您试图在
ajax
中发出
alert
,这是语法错误。尝试删除
ajax
中的
警报
,它应该可以工作

您可以在
success
中使用
alert
error
回调,如下所示:

$(function checkUsertype(email_id) {
    var usertype = $("#txtusertype").val();
    $.ajax({
        url: 'rest/search/userType?email_id=' + email_id,
        type: "GET",
        datatype: 'json',
        cache: false,
        success: function(data) {
            alert('In Success'); // Use it here
            console.log(data); // Log the response
            if (usertype == 'webuser') {
                $("#themer").hide();
            }
        },
        error: function(xhr, data, statusText, errorThrown) {
            alert('In Error'); // Use it here
            console.log(errorThrown); // Log the error
        }
    });
});
这就是问题所在

$.ajax({    
    alert("hide")
您试图在
ajax
中发出
alert
,这是语法错误。尝试删除
ajax
中的
警报
,它应该可以工作

您可以在
success
中使用
alert
error
回调,如下所示:

$(function checkUsertype(email_id) {
    var usertype = $("#txtusertype").val();
    $.ajax({
        url: 'rest/search/userType?email_id=' + email_id,
        type: "GET",
        datatype: 'json',
        cache: false,
        success: function(data) {
            alert('In Success'); // Use it here
            console.log(data); // Log the response
            if (usertype == 'webuser') {
                $("#themer").hide();
            }
        },
        error: function(xhr, data, statusText, errorThrown) {
            alert('In Error'); // Use it here
            console.log(errorThrown); // Log the error
        }
    });
});
这就是问题所在

$.ajax({    
    alert("hide")
您试图在
ajax
中发出
alert
,这是语法错误。尝试删除
ajax
中的
警报
,它应该可以工作

您可以在
success
中使用
alert
error
回调,如下所示:

$(function checkUsertype(email_id) {
    var usertype = $("#txtusertype").val();
    $.ajax({
        url: 'rest/search/userType?email_id=' + email_id,
        type: "GET",
        datatype: 'json',
        cache: false,
        success: function(data) {
            alert('In Success'); // Use it here
            console.log(data); // Log the response
            if (usertype == 'webuser') {
                $("#themer").hide();
            }
        },
        error: function(xhr, data, statusText, errorThrown) {
            alert('In Error'); // Use it here
            console.log(errorThrown); // Log the error
        }
    });
});
这就是问题所在

$.ajax({    
    alert("hide")
您试图在
ajax
中发出
alert
,这是语法错误。尝试删除
ajax
中的
警报
,它应该可以工作

您可以在
success
中使用
alert
error
回调,如下所示:

$(function checkUsertype(email_id) {
    var usertype = $("#txtusertype").val();
    $.ajax({
        url: 'rest/search/userType?email_id=' + email_id,
        type: "GET",
        datatype: 'json',
        cache: false,
        success: function(data) {
            alert('In Success'); // Use it here
            console.log(data); // Log the response
            if (usertype == 'webuser') {
                $("#themer").hide();
            }
        },
        error: function(xhr, data, statusText, errorThrown) {
            alert('In Error'); // Use it here
            console.log(errorThrown); // Log the error
        }
    });
});


什么是
*
?这些是复制粘贴错误吗?是..在堆栈中粘贴时?什么是
*
?这些是复制粘贴错误吗?是..在堆栈中粘贴时?什么是
*
?这些是复制粘贴错误吗?是..在堆栈中粘贴时?什么是
*
?这些是复制粘贴错误吗?是..在堆栈中粘贴时?是..删除后,第一个警报正在工作,但第二个警报不工作编译器没有进入methodconsole.log(在这里面我必须给出什么?)tanx bro..现在我可以在控制台中看到一些东西得到这个错误r:Uncaught ReferenceError:$未定义?是的…删除它后,第一个警报工作,但第二个警报不工作编译器没有进入methodconsole.log(在这里面我必须给出什么?)tanx bro..现在我可以在控制台中看到一些东西得到这个错误r:Uncaught ReferenceError:$未定义?是的…删除它后,第一个警报工作,但第二个警报不工作编译器没有进入methodconsole.log(在这里面我必须给出什么?)tanx bro..现在我可以在控制台中看到一些东西得到这个错误r:Uncaught ReferenceError:$未定义?是的…删除它后,第一个警报工作,但第二个警报不工作编译器没有进入methodconsole.log(在这里面我必须给出什么?)tanx bro..现在我可以在控制台中看到一些东西得到这个错误r:uncaughtreferenceerror:$未定义?