douxuanjie2692 2011-08-07 10:00
浏览 63
已采纳

Jquery 1.6.2不适用于数据类型:json

I'm making a signup form in which i've used following function for validate signup this function is called when a form is attempted to submit.

$.ajax({
    type: "POST",
    url: "view/ajax/php/checkcap.php",
    data: $('#capform').serialize(),
    dataType: "json",
    async: false,
    success: function(msg){
        alert(msg.txt);
        // other validations
    }
})

here alert is just for display response from checkcap.php file. it works perfectly with jquery 1.3.2 however i've upgraded the jquery 1.3.2 to 1.6.2. after using jquery 1.6.2, however function gets response from the php file (checked using firebug) but can't display the message (response from php file). how to make the code work with jquery 1.6.2 ?

  • 写回答

1条回答 默认 最新

  • dragon8002 2011-08-07 10:08
    关注

    make sure the json format is

    {
      "one": "Singular sensation",
      "two": "Beady little eyes",
      "three": "Little birds pitch by my doorstep"
    }
    

    http://api.jquery.com/jQuery.getJSON/

    You are missing double quotes on propertynames

    {"status":0,"txt":"a"}   ---correct
    {status:0,txt:"a"}       ---wrong
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统