ajax请求不等服务器返回直接进入error

本文描述了一个Ajax请求在服务器未完成响应时直接进入error的情况。问题出现在使用a标签并触发onclick事件时,若href未设置为'#',会导致请求异常。通过将a标签的href属性设为'#',问题得到解决。
摘要由CSDN通过智能技术生成
function publishTopic(){
	var subjectId = $("#subjectId").attr("value");
	var topicContent = $("#topicContent").val();
	if (topicContent==null || typeof(topicContent)=="undefined" || topicContent==""){
		alert("评论内容不能为空!!!");
	}
	
	$.ajax({
		  url: "/topic/publishTopic.action",
	      type: "POST",
	      data: "topicAbstractInfoVO.belongSubjectId="+subjectId+"&r="+ (new Date()).getTime(),
	      dataType: "json",
	      async:true,
	      success: function(reMsg){
	    	  alert(reMsg);
	    	  console.log("111"+reMsg);
	    	  var a=0
	    	  var b=1;
	    	  b=a+b;
	    	  alert("111111111");
	    	  /*if(reMsg.success==true){
	    		  window.location.href = "/index.action?topicAbstractInfoVO.belongSubjectId="+subjectId
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值