I have an HTML form and send data to php file when hitting submit button.
$.ajax({
url: \"text.php\",
type: \"POST\",
data: {
amount: amount,
You're converting resulting object to string instead of displaying it.
Instead of result, if you want print object inside some wrapper, you can do something like this:
var text = '{';
for(var i in data) {
var value = data[i];
text += '"'+i+'":"'+value+'", ';
}
text += '}';
$('#result').text(text);
But you may consider that console.log
is much easier and faster way to see the response in json format.