I am sending post data to saveworld.php and getting some result in that page and I
want to use that data in the present page .My problem is I am getting the entire DOM
of saveworld.php.But I need only some specific text in a div having an id as linkid
this is my code
$.ajax({
type: "POST",
url: "saveworld.php",
data: worldData,
success: function(data) {
if (data.length > 0) {
$('#space').append("<a id='" + data + "' class='square' style='background-color:#" + color2 + ";color:#" + tcolor2 + ";' href='worlds/" + data + "'>" + name2 + "</a>")
}
}
});
i want a specific data for example I want the following data which was present in saveworld.php
<div id='linkid'>23</div>
I suppose it will be something like ($('#linkid',data)) to get that data but I am getting [Object Object ] using that
But I want to use the specific part of the data of the response page saveworld.php
If your php script return a piece of JSON code, you have to decode your JSON like that :
And after you can use your data as you rendered your table on your PHP script :
The better way to your php script is to test if your piece of code was executed well.
You render a php table with a bool for the execution check test:
on your js code, it will look like :