diff --git a/context/output.go b/context/output.go index 17404702..3437b2c4 100644 --- a/context/output.go +++ b/context/output.go @@ -208,7 +208,8 @@ func (output *BeegoOutput) JSONP(data interface{}, hasIndent bool) error { if callback == "" { return errors.New(`"callback" parameter required`) } - callbackContent := bytes.NewBufferString(" " + template.JSEscapeString(callback)) + callback = template.JSEscapeString(callback) + callbackContent := bytes.NewBufferString(" if(window." + callback + ")" + callback) callbackContent.WriteString("(") callbackContent.Write(content) callbackContent.WriteString(");\r\n")