Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php parsererror SyntaxError:JSON.parse:JSON数据第1行第190列的JSON数据后出现意外的非空白字符_Php_Jquery_Ajax - Fatal编程技术网

Php parsererror SyntaxError:JSON.parse:JSON数据第1行第190列的JSON数据后出现意外的非空白字符

Php parsererror SyntaxError:JSON.parse:JSON数据第1行第190列的JSON数据后出现意外的非空白字符,php,jquery,ajax,Php,Jquery,Ajax,当我点击按钮时,我发现上面的JSON错误。它不返回任何值。你能帮我解决这个问题吗 这里是我的Jquery代码 $(document).ready(function(){ $('.package_details').click(function(){ $('.txt-form').slideDown("slow"); var package = $(this).attr("id"); $.ajax({ type:"post", url:"aa

当我点击按钮时,我发现上面的JSON错误。它不返回任何值。你能帮我解决这个问题吗

这里是我的Jquery代码

$(document).ready(function(){
  $('.package_details').click(function(){

    $('.txt-form').slideDown("slow");
    var package = $(this).attr("id");

    $.ajax({
      type:"post",
      url:"aaa.php", 
      dataType: 'json',
      data:"pack="+pack,
      success:function(html){

        $('.package_name').val(html.package_name);
        $('.package_price').val(html.package_price);

        $('.discount_percentage').val(html.discount);
        $('.amount_after_discount').val(html.amnt_discount);
        $('.tax_percentage').val(html.tax);
        $('.amount_after_tax').val(html.amnt_tax);

        if(html.package_type == 'Contact Visible'){
          $('.contact').attr('checked', 'checked');
        }else if(html.package_type == 'Job post'){
          $('.job').attr('checked', 'checked');
        }else if(html.package_type == 'Both'){
          $('.both').attr('checked', 'checked');
        }

        $('.contact_visible').val(html.count);
        $('.job_post').val(html.job_post);
        $('.valitity_day').val(html.valitity);
      },
    error: function (jqXHR, textStatus, errorThrown) {
        alert('Not done - ' + textStatus + ' ' + errorThrown);
    }
    })
  })
})
这里是我的PHP代码

echo json_encode(array("package_name"=>$package_name,"package_type"=>$package_type,"discount"=>$discount,"amnt_discount"=>$amnt_discount,"tax"=>$tax,"amnt_tax"=>$amnt_tax,"count"=>$count,"job_post"=>$job_post,"package_price"=>$package_price,"valitity"=>$valitity));

创建如下所示的json变量,然后将其发布到数据字段中

post_data =  {  "pack": pack};

$.ajax({
      type:"post",
      url:"aaa.php", 
      dataType: 'json',
      data:post_data,
.
.
.

您没有以json格式发送数据它在过去完全有效,但现在返回错误my code是否有任何问题请使用success function中的console.log(html)查看html中有什么内容这些都是ajax函数转到success handler时的文本框值,这些值可能会替换json值我尝试按照您的代码执行。但现在我还是犯了同样的错误。