drsb77336 2010-12-15 13:54
浏览 66
已采纳

使用AJAX和Jquery的PHP行为真的很奇怪

Well, my problems is a little wierd,

I have an AJAX Request to get just a number.

That number is printed on: getMoney.php. On index.php i have the AJAX request.

Ajax Code:

function getMoney(selected)
        {
            if(selected.value != -1)
            {
                // Obtener presupuesto via AJAX
                $(document).ready(function(){
                    $.ajax({
                            url: "getMoney.php",
                            async: true,
                            success: function(datos){
                                //My action
                            }
                    });
                });
            }
        }

The function is called when I change a value on a Combobox HTML

<select name="area_id" onchange="getMoney(this);">

Well... My problem: If i write down the numbers on getMoney.php (mannualy) its works perfectly, the AJAX's get it and the action is done, but when i get the numbers from my database i just get 0. I open mannualy too the getMoney.php, and the numbers ARE THERE! even if i get it from the Database.

What's wrong?

  • 写回答

3条回答 默认 最新

  • duanjiao4763 2010-12-15 14:01
    关注

    make sure that getMoney.php is NOT using your standard view headers, i.e. script includes, stylesheet includes or anything else. Also, it's better practice to have getMoney.php to return a JSON string with your data parametized that way you can pull back diagnosic and error codes as well as specific data. this will help in debugging. look at $.getJSON() if you need help with that.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教