jQuery ajax responseText 'undefined'

I've got some jQuery which posts two variables to a php script. The PHP is very simple and simply returns a string based on what it's given, i.e. 'update successful' which I'd like to use in some way on the page. The first time I click I get an alert saying 'undefined', any further clicks and everything works fine. Pretty sure I'm not far off but I can't work out this problem! I've used firebug and the data is posted and the correct response is received on all attempts. $(document).ready(function(){ $('#updatehol').click(function() { additions = $('#additions').attr('value'); deductions = $('#deductions').attr('value'); datastring = 'additions='+ additions +'&deductions='+ deductions; $.ajax({ type: "POST", data: datastring, url: "doadjust.php", complete: function(data) { alert(data.responseText); } }); }); });

以上就是jQuery ajax responseText 'undefined'的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏