public function actionSendverify($id) {
// do something like load a model and set verified to true
// after set verified true returns new status
return 'mail sended...';
}
Is there a solution how i can show the return status in the div with id=test? Or must i do that with an javascript and ajax?
If you only want to change the content of one div without reloading the page you need an Ajax request and Javascript.
Otherwise you’ll have to reload the entire page but I would rather suggest the js way
Thank you for you answer. I thought so. Does Yii have a way to do this without an external JS file?
So far I’ve been writing Javascript functions which call a controller function via Ajax. But I don’t think it’s so good if you can later view the javascript functions by downloading the files.
The question is: what is the difference for you if Yii2 does this request or if you write it.
In the end people can always download both script files and see what happens.
As soon as your request is done everyone can see it in their Console - no matter what.
There is no need to try to cover your JS. You can minify + uglyfy it tho but there is no reliable way to cover it from people who really want to see it. Furthermore as said, the Browser Console can still provide all the information…
For example just in case you never worked with it. When you submit a Post here:
You can see all the form-submit data
So it’s easy to find out what happened and how to use it. Even without your JS.
You can even copy your Ajax call, paste it in software like postman and re-send it as often as you wish with manipulated POST data