Skip to content

Commit e3f33ef

Browse files
authored
Merge pull request #70 from surveyjs/feature/63-handling-network-errors
PR: Handling errors when saving to database or sending email
2 parents cabf11a + 9b10fff commit e3f33ef

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/trunk/initializer.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,19 +195,21 @@ function initSurvey<?php echo $id ?>(json, theme) {
195195
if (!!theme) {
196196
survey<?php echo $id ?>.applyTheme(theme);
197197
}
198-
window.survey<?php echo $id ?> = survey<?php echo $id ?>;
198+
window.survey<?php echo $id ?> = survey<?php echo $id ?>;
199199
survey<?php echo $id ?>
200200
.onComplete
201-
.add(function (result) {
201+
.add(function (sender, options) {
202+
options.showSaveInProgress();
202203
jQuery.ajax({
203204
url: "<?php echo esc_url($saveResultUri) ?>",
204205
type: "POST",
205-
data: { SurveyId: '<?php echo $id ?>', Json : JSON.stringify(result.data) },
206-
success: function (data) {}
206+
data: { SurveyId: '<?php echo $id ?>', Json : JSON.stringify(sender.data) },
207+
success: function (data) {options.showSaveSuccess();},
208+
error: function (xhr) {options.showSaveError(xhr.responseText);}
207209
});
208210
//document
209211
// .querySelector("#surveyResult-<?php echo $id ?>")
210-
// .innerHTML = "result: " + JSON.stringify(result.data);
212+
// .innerHTML = "result: " + JSON.stringify(sender.data);
211213
});
212214

213215
survey<?php echo $id ?>.onUploadFiles.add((_, options) => {

0 commit comments

Comments
 (0)