Robert Glavaš Robert Glavaš - 2 months ago 20
Javascript Question

Jquery div to PHP data

I have some java script:



$.getJSON("http://ip-api.com/json/google.hr", function(data) {
var table_body = "";
$("#mojetrebam").html(data.status);
$.each(data, function(k, v) {
table_body += "<tr><td>" + k + "</td><td><b>" + v + "</b></td></tr>";
});});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="mojetrebam"></div>





My question is, how javascript result ('success') add in some PHP variable
like

$mystatus = "<div id=\"mojetrebam\"></div>";

Answer

Your PHP code $mystatus = "<div id=\"mojetrebam\"></div>"; need work.

Be sure that your JAVASCRIPT is in same PHP page wher you have your PHP code.

Comments