Skip to content

Commit 51c7be6

Browse files
committed
minor changes
1 parent 83f4fb7 commit 51c7be6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Factories/JavascriptFactory.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,23 +115,27 @@ protected function useJquery()
115115
*/
116116
protected function constructAjaxCall()
117117
{
118+
$ajaxLink = $this->ajaxLink;
119+
$containerId = $this->getContainerId();
120+
$data = $this->produceJavascriptData();
121+
118122
if ($this->useJquery()) {
119123
$id = WidgetId::get();
120124

121125
return
122126
"var widgetTimer{$id} = setInterval(function() {".
123127
'if (window.$) {'.
124-
"$('#{$this->getContainerId()}').load('".$this->ajaxLink."', {$this->produceJavascriptData()});".
128+
"$('#{$containerId}').load('".$ajaxLink."', {$data});".
125129
"clearInterval(widgetTimer{$id});".
126130
'}'.
127131
'}, 100);';
128132
}
129133

130134
return
131135
'var xhr = new XMLHttpRequest();'.
132-
'var params = '.$this->produceJavascriptData().';'.
133-
'var container = document.getElementById("'.$this->getContainerId().'");'.
134-
'xhr.open("POST", "'.$this->ajaxLink.'", true);'.
136+
'var params = '.$data.';'.
137+
'var container = document.getElementById("'.$containerId.'");'.
138+
'xhr.open("POST", "'.$ajaxLink.'", true);'.
135139
'xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");'.
136140
'xhr.send(params);'.
137141
'xhr.onreadystatechange = function() {'.

0 commit comments

Comments
 (0)