When running this php script :
$doc = new DOMDocument();
$doc->loadHTMLFile("../counter.html");
$ele2 = $doc->getElementById ( "coupon_id" );
if($ele2){
$ele2->nodeValue = $result["coupon_code"];
}
$response["list"]= $doc->saveHTML();
$ele2 is found to be null on my web server an so it does not enter to the if condition, but it works fine on my local server. Here is my counter.html file :
<div class="panel panel-success">
<div class="panel-heading">
<h3 id="coupon" class="panel-title">Coupon name 1</h3>
</div>
<p id="coupon_id" hidden>coupon id</p>
<div id="counter-up" class="panel-body">
0
</div>
</div>
I already made sure the html file was loaded successfully by doing : echo "<pre>".$doc->saveHTML()."</pre>";