Search code examples
phphtmlquoting

I am using ordertable for server side response.Html tag double quotes are mismatched in jsonencode response


I am sending data from controller using json_encode():

$status =     "<td id=status_".$value['id'].">".
                  "<button class='btn btn-icon-toggle active'  href='javascript:;' onclick='changeStatus(".$value['id'].", '0', ".$field.", ".$url.",".$action.")><i class='fa fa-check'></i>
                   </button> </td>";

The Output are:

<button class="btn btn-icon-toggle active" href="javascript:;" onclick="changeStatus(1510, " 0',="" status,="" stores="" ajaxaction,restaurantstatus)="">

I need output is:

<button class="btn btn-icon-toggle active" href="javascript:;" onclick="changeStatus(1510,0,'status','stores/ajaxaction','restaurantstatus')">

what will I do???


Solution

  • Just learn the string escape characters and play with it!

    $status = "<td id=\"status_".$value['id']."\">" . "<button class=\"btn btn-icon-toggle active\"  href=\"javascript:;\" onclick=\"changeStatus(".$value['id'].", 0, '".$field."', '".$url."','".$action."')\"><i class=\"fa fa-check\"></i> </button> </td>";