-5

I want to create a solution like the Dropbox one, to display the result of an operation like a post, within an html page. Here is the output that I want:

enter image description here

So once the system has completed a task (like add or delete an item), an alert should be displayed in green if the operation has been successfully done, or red if some error happened. How Can I do this ? It is something like the Toast in Android, where the user get the result of the operation, without any alert.

UPDATE with CODE:

This is the HTML code I'm using with alert:

function send(player, price) {
        $.post("./php/myphp.php", {
            player : player,
            price : price
        }).done(function(data) {
            alert(data);
            location.reload();
        });
    }

And here is the PHP code:

if (isset ( $_POST ["giocatore"] ) && ! empty ( $_POST ["prezzo"] )) {
  echo "OK: The operation has been done correctly !";
}else{
  echo "Error: The data you send are not correctly. Please check it !";
}
3
  • 2
    you need to show what you have tried Aug 1, 2015 at 18:54
  • Add code please, responses will depend on the existing structure of your application. Aug 1, 2015 at 18:56
  • I've updated the question. I hope now the question will be more easy to understand ! Aug 9, 2015 at 19:34

1 Answer 1

1

I think you can do this:

Suppose that an operation is a request, make an positive alert in the success handler. By an error, do a negative alert in the error handler.

That's generally the trick: check if an operation successful is completed or not.

You can make easy an alert bar in html and css: div element with green or red background and specific id.

See also the following link for a small example: Display message after success of function with ajax

1
  • Thank you, your solution is very good and easy to implement ! Aug 9, 2015 at 19:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.