前台json获取值获取正确。但if条件的json接收不到:
HTML code
('#test_ajax').click(function() { $.ajax({ data : 'msg=hello', url : 'index.php', type : 'post', contentType: "application/text; charset=utf-8", /*则注意看这边的与html中是否输入设置类型Check your code for duplicated meta cache-control and remove one of them:
<meta http-equiv="cache-control" content="no-cache" /> */
dataType : 'json', success : function(data){ alert(data); } }); });
或用post方法$.post('checkmoney', {fieldname:fieldname,moneyvalue:moneyvalue}, function(json){ console.log(json); if(json === "false"){ alert('1231'); alert("消费金额不能设置成同一级别"); }else { alert("success"); } },'json'); //注意是否有json参数