繁体   English   中英

为什么ajax调用不能在相同的URL下正常工作?

[英]Why the ajax call is not working properly with same url?

有两个具有相同网址的Ajax调用无法正常工作?

var ss=35;
function t()
{
$.ajax({type:"POST",
          url:"BillServlet",
          data1:{message1:ss},                                                                 
          success:function(data1){
          alert('success'+data1.message1)
          }});} //this function returns null

function test()
{
$.ajax({type:"POST",
          url:"BillServlet",
          data:{message:total},                                                                 
          success:function(data){
          alert('success'+data.message)
          }});}//this function returns value

为什么一个函数返回空值?

假设您试图通过两个函数从服务器获取相同的数据,则在function t() ,应将data1.message1更改为data1.message

否则,请尝试打印出data1的值以查看服务器实际为您提供的数据。 如果由于某种原因无法使用console.log(data1) ,则也可以使用alert(JSON.stringify(data1))

检入firbug,您是否从服务器获得响应? 我认为您正在从服务器得到空白响应。 如果您得到响应,请检查响应中与您警报相同的索引。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM