dai-idiot

<button>点击发送ajax get请求</button>

<button>点击发送ajax post请求</button>

<button>点击发送通用的ajax请求</button>

<script type="text/javascript" src="jquery-1.8.3.min.js"></script>

<script type="text/javascript">

get方法发送请求

$(\'button\').eq(0).click(function(){

//发送ajax请求   

$.get(\'1.php\',{a:100,b:200},function(data){

alert(data);

})

})

  post发送发送请求

$(\'button\').eq(1).click(function(){

$.post(\'1.php\',{a:100,b:200},function(data){

alert(data);

})

})

//通用ajax请求方法

$(\'button\').eq(2).click(function(){

var a = 100;

$.ajax({

url: \'1.php\',

type: \'GET\',

data: {a:\'love\',b:\'you\'},

async: true,

// dataType: \'json\',

success: function(data){

a=200;

// alert(data);

},

error:function(){

alert(\'error\');

},

timeout: 300

});

alert(a);

})

</script>

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-11-30
  • 2021-12-08
  • 2021-08-11
  • 2021-11-23
  • 2021-08-03
  • 2022-12-23
猜你喜欢
  • 2021-11-23
  • 2022-01-09
  • 2021-12-21
  • 2022-01-10
  • 2021-08-18
  • 2022-03-04
相关资源
相似解决方案