Datatables parse error in HTML.

Datatables parse error in HTML.

laroccalarocca Posts: 3Questions: 1Answers: 0
edited June 2014 in Free community support

Hi guys, I'm looking a issue in my code and not sure how to solve it.
I have this code:

$json .= "\"<div id='idNominatim".$lst["id"]."'><center><button  onclick=getNominatim('".$lst["red_latitude"]."','".$lst["red_longitude"]."', '".$lst["id"]."') type='button' class='btn'><i class='icon-globe'></i> Resolver</button></center></div>\"";

But in HTML, datatables is showing this:

<button class="btn" type="button" '147')="" onclick="getNominatim('-27.772642','-054.230390',"><i class="icon-globe"></i> Resolver</button>

here my json (parse is ok):

"aaData":[
    [
        "147",
        "IFT 0000",
        "Automóvel",
        "<center><i class='icol-lightbulb'></i></center>",
        "<center>12-06-2014 11:00:07</center>",
        "<center> <i class='icol32-error'> </i> <i class='icol32-bullet-green' alt='Comunicação Online'> </i></center>",
        "<div id='idNominatim147'><center><button onclick=getNominatim('-27.772724','-054.230383', '147') type='button' class='btn'><i class='icon-globe'></i> Resolver</button></center></div>"
    ],

Did you saw this before? Appears to be a bug in datatables, since if I delete '".$lst["id"]."' from the function, HTML works fine.

Answers

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    What happens if you remove the onclick attribute? That doesn't look quite valid to me.

    Allan

  • laroccalarocca Posts: 3Questions: 1Answers: 0

    but I need the onclick, since I need to call that function.

  • laroccalarocca Posts: 3Questions: 1Answers: 0

    solved:

    htmlspecialchars("getNominatim('".$redLat."','".$redLon."', '".$idVehicle."')", ENT_QUOTES);
    
This discussion has been closed.