These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace hipanel\widgets; |
||
4 | |||
5 | use hipanel\actions\Action; |
||
6 | use yii\helpers\Json; |
||
7 | use yii\web\View; |
||
8 | |||
9 | trait HookTrait |
||
10 | { |
||
11 | public ?string $url = null; |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
12 | |||
13 | public function registerJsHook(string $reqHeaderParamName): void |
||
14 | { |
||
15 | $id = $this->getId(); |
||
16 | $headerName = Action::EXPECTED_AJAX_RESPONSE_HEADER_NAME; |
||
17 | $url = $this->url ? Json::encode($this->url) : 'document.URL'; |
||
18 | $this->view->registerJs("$.ajax({ |
||
19 | type: 'GET', |
||
20 | url: {$url}, |
||
21 | beforeSend: xhr => { |
||
22 | xhr.setRequestHeader('{$headerName}', '{$reqHeaderParamName}'); |
||
23 | }, |
||
24 | success: html => { |
||
25 | $('#{$id}').html(html); |
||
26 | } |
||
27 | });", View::POS_LOAD); |
||
28 | } |
||
29 | } |
||
30 |