ajax跨域调用和非跨域调用的写法

前端之家收集整理的这篇文章主要介绍了ajax跨域调用和非跨域调用的写法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  1. //支持跨域调用
  2. $.ajax({
  3. type:"POST",async :false,url:"http://web3.com:9080/authority/dept/hellob.shtml?userName=zqb&callback=?",dataType:"jsonp",success:function(data){
  4. //alert(data);
  5. console.log(data);
  6. },error:function(){
  7. alert("error");
  8. }
  9. });
  10.  
  11. }
  12. //不支持跨域调用
  13. function b(){
  14. $.ajax({
  15. type: "post",dataType: "html",url: "http://web3.com:9080/authority/dept/hellob.shtml?userName=zqb",data: "",success: function (data) {
  16. console.log(data);
  17. }
  18. });
  19. }

猜你在找的Ajax相关文章