Javascript jqueryajax调用不';好像不行

Javascript jqueryajax调用不';好像不行,javascript,jquery,ajax,Javascript,Jquery,Ajax,我试图用jqueryajax调用一个页面,然后显示一个简单的响应,不管它是否有效,但它似乎没有完成任何事情。在FireBug中,我甚至没有出错。我做错了什么 <script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script> <script> $('.doit').click(function (e) { e.preventDefault()

我试图用jqueryajax调用一个页面,然后显示一个简单的响应,不管它是否有效,但它似乎没有完成任何事情。在FireBug中,我甚至没有出错。我做错了什么

<script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>

<script>
$('.doit').click(function (e) {
  e.preventDefault();
  $.ajax({
    url: "https://www.domain.com/page.php?do=it",
    type: "GET"
    success: function (data) {
        $(".result").html('<strong>Done!</strong>');
    },
    error: function (xhr, ajaxOptions, thrownError) {
        $(".result").html('<strong>Houston, we have a problem.</strong>');
    },
    timeout: 15000
  });
});
</script>

<a href="" class="doit">Do it</a>

<div class="result"></div>

$('.doit')。单击(函数(e){
e、 预防默认值();
$.ajax({
url:“https://www.domain.com/page.php?do=it",
键入:“获取”
成功:功能(数据){
$(“.result”).html(“完成!”);
},
错误:函数(xhr、ajaxOptions、thrownError){
$(“.result”).html(“休斯顿,我们有一个问题。”);
},
超时:15000
});
});

您在
键入“GET”
后漏掉了逗号。此外,正如@blex在评论中提到的,您应该将绑定放在ondomready上下文中,以确保在绑定之前已加载元素

 $(function(){
    $('.doit').click(function (e) {
      e.preventDefault();
      $.ajax({
        url: "https://www.domain.com/page.php?do=it",
        type: "GET",
        success: function (data) {
            $(".result").html('<strong>Done!</strong>');
        },
        error: function (xhr, ajaxOptions, thrownError) {
            $(".result").html('<strong>Houston, we have a problem.</strong>');
        },
        timeout: 15000
      });
    });
 });
$(函数(){
$('.doit')。单击(函数(e){
e、 预防默认值();
$.ajax({
url:“https://www.domain.com/page.php?do=it",
键入:“获取”,
成功:功能(数据){
$(“.result”).html(“完成!”);
},
错误:函数(xhr、ajaxOptions、thrownError){
$(“.result”).html(“休斯顿,我们有一个问题。”);
},
超时:15000
});
});
});

您在
键入“GET”
后漏掉了逗号。此外,正如@blex在评论中提到的,您应该将绑定放在ondomready上下文中,以确保在绑定之前已加载元素

 $(function(){
    $('.doit').click(function (e) {
      e.preventDefault();
      $.ajax({
        url: "https://www.domain.com/page.php?do=it",
        type: "GET",
        success: function (data) {
            $(".result").html('<strong>Done!</strong>');
        },
        error: function (xhr, ajaxOptions, thrownError) {
            $(".result").html('<strong>Houston, we have a problem.</strong>');
        },
        timeout: 15000
      });
    });
 });
$(函数(){
$('.doit')。单击(函数(e){
e、 预防默认值();
$.ajax({
url:“https://www.domain.com/page.php?do=it",
键入:“获取”,
成功:功能(数据){
$(“.result”).html(“完成!”);
},
错误:函数(xhr、ajaxOptions、thrownError){
$(“.result”).html(“休斯顿,我们有一个问题。”);
},
超时:15000
});
});
});

您在
键入“GET”
后漏掉了逗号。此外,正如@blex在评论中提到的,您应该将绑定放在ondomready上下文中,以确保在绑定之前已加载元素

 $(function(){
    $('.doit').click(function (e) {
      e.preventDefault();
      $.ajax({
        url: "https://www.domain.com/page.php?do=it",
        type: "GET",
        success: function (data) {
            $(".result").html('<strong>Done!</strong>');
        },
        error: function (xhr, ajaxOptions, thrownError) {
            $(".result").html('<strong>Houston, we have a problem.</strong>');
        },
        timeout: 15000
      });
    });
 });
$(函数(){
$('.doit')。单击(函数(e){
e、 预防默认值();
$.ajax({
url:“https://www.domain.com/page.php?do=it",
键入:“获取”,
成功:功能(数据){
$(“.result”).html(“完成!”);
},
错误:函数(xhr、ajaxOptions、thrownError){
$(“.result”).html(“休斯顿,我们有一个问题。”);
},
超时:15000
});
});
});

您在
键入“GET”
后漏掉了逗号。此外,正如@blex在评论中提到的,您应该将绑定放在ondomready上下文中,以确保在绑定之前已加载元素

 $(function(){
    $('.doit').click(function (e) {
      e.preventDefault();
      $.ajax({
        url: "https://www.domain.com/page.php?do=it",
        type: "GET",
        success: function (data) {
            $(".result").html('<strong>Done!</strong>');
        },
        error: function (xhr, ajaxOptions, thrownError) {
            $(".result").html('<strong>Houston, we have a problem.</strong>');
        },
        timeout: 15000
      });
    });
 });
$(函数(){
$('.doit')。单击(函数(e){
e、 预防默认值();
$.ajax({
url:“https://www.domain.com/page.php?do=it",
键入:“获取”,
成功:功能(数据){
$(“.result”).html(“完成!”);
},
错误:函数(xhr、ajaxOptions、thrownError){
$(“.result”).html(“休斯顿,我们有一个问题。”);
},
超时:15000
});
});
});

之后键入:“GET”
并将您的JS包装在
$(文档)中。ready(function(){your code here})
,以便定义
.doit
。否则它可能不起作用。就是这样,谢谢大家!:)如果你发布官方回复,我会接受!完成。只是等了几分钟。谢谢:)在
之后键入:“GET”
并将您的JS包装在
$(文档)中。ready(function(){your code here})
,以便定义
.doit
。否则它可能不起作用。就是这样,谢谢大家!:)如果你发布官方回复,我会接受!完成。只是等了几分钟。谢谢:)在
之后键入:“GET”
并将您的JS包装在
$(文档)中。ready(function(){your code here})
,以便定义
.doit
。否则它可能不起作用。就是这样,谢谢大家!:)如果你发布官方回复,我会接受!完成。只是等了几分钟。谢谢:)在
之后键入:“GET”
并将您的JS包装在
$(文档)中。ready(function(){your code here})
,以便定义
.doit
。否则它可能不起作用。就是这样,谢谢大家!:)如果你发布官方回复,我会接受!完成。只是等了几分钟。谢谢:)