weixin_33738578 2016-04-22 19:14 采纳率: 0%
浏览 24

jQuery ajax结果数据

I'm having trouble using the return data within my ajax call. What is the best way to go about this?

I simply send information to checker.jsp. It computes it. If the check is good, it responds with a Green. If it's bad, it responds with a Red.

If I use this within the success:

alert(light_color);

I get what seems to be the entire web page with the word "Red" 40 lines down. Because of this the if and elses do not work. I want to use the result and only the result. Not the html and everything in it.

What am I doing wrong?

Any help would be appreciated!

 $.ajax({
        type: 'POST',
        url: 'checker.jsp',
        data: {
            'bank_cnt': bank_cnt
        },
        success: function (result) {
            var light_color = result;
            if (light_color === 'Red') {
              alert('Red');  
            } else if (report === 'Green') {
                alert('Green');
            } else {
                alert('didnt work');
            }
        }
    });
  • 写回答

3条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 有偿找一份verilog语言的cnn代码带讲解
      • ¥15 关于#mysql#的问题:mysql 组内排名,取各组的销售金额前10
      • ¥15 有人用过颜色传感器吗?
      • ¥50 求一个SQL长料切短料的优化排版算法
      • ¥15 python 删除TXT文档中小写字母
      • ¥15 ValueError: not enough values to unpack (expected 2, got 0)
      • ¥15 js怎么禁止修改域名
      • ¥15 Cursor为什么在Windows11打不开
      • ¥30 java调用javacv遇到的问题
      • ¥15 如何使用matlab画出带宽100Khz,时长100ms信号的LFM形式的时频图啊