Hi,
Got a strange problem when my application is deployed to my web server.
When opening the PDF Viewer I get the following Error:
ejs.interop.min.js:1 Unexpected token T in JSON at position 0
SyntaxError: Unexpected token T in JSON at position 0
at JSON.parse (<anonymous>)
at e.loadRequestHandler.onSuccess (https://cdn.syncfusion.com/ej2/17.4.39/dist/ej2.min.js:10:9101404)
at e.successHandler (https://cdn.syncfusion.com/ej2/17.4.39/dist/ej2.min.js:10:9239995)
at Object.ioSuccessHandler (https://cdn.syncfusion.com/ej2/17.4.39/dist/ejs.interop.min.js:1:20011)
at https://dev.medco.awesomesource.dev/_framework/blazor.server.js:8:31421
at new Promise (<anonymous>)
at e.beginInvokeJSFromDotNet (https://dev.medco.awesomesource.dev/_framework/blazor.server.js:8:31390)
at https://dev.medco.awesomesource.dev/_framework/blazor.server.js:1:19202
at Array.forEach (<anonymous>)
at e.invokeClientMethod (https://dev.medco.awesomesource.dev/_framework/blazor.server.js:1:19173)
I do not get this error when running on my development machine an debugging from Visual Studio. I am referencing the latest version of everything.
Any Ideas if I am perhaps missing a dependency on my web server - but I don't think I am as this did work with the previous version of Syncfusion.
I am referencing the javascript files via your CDN
...
<link rel='nofollow' href="https://cdn.syncfusion.com/ej2/17.4.39/material.css" rel="stylesheet" />
<script src="https://cdn.syncfusion.com/ej2/17.4.39/dist/ej2.min.js"></script>
<script src="https://cdn.syncfusion.com/ej2/17.4.39/dist/ejs.interop.min.js"></script>
...
Code as follows: ViewPDF.Razor
@using Medco.Models
@using Medco.Models.ViewModels
@using Syncfusion.EJ2.Blazor.Calendars
@using Syncfusion.EJ2.Blazor.Popups
@using Syncfusion.EJ2.Blazor.DropDowns
@using Syncfusion.EJ2.Blazor.Inputs
@using Syncfusion.EJ2.Blazor.PdfViewerServer
@if (DocumentPath != null)
{
<EjsPdfViewerServer DocumentPath="@DocumentPath" Width="100%" Height="850px"></EjsPdfViewerServer>
}
@code {
[Parameter] public string DocumentPath { get; set; }
}
And the code which sets the DocumentPath parameter is as follows (it is a byte array converted to base 64 string) : ViewPDFDialog.razor
@using Medco.Models
@using Medco.Models.ViewModels
@using Syncfusion.EJ2.Blazor.Calendars
@using Syncfusion.EJ2.Blazor.Popups
@using Syncfusion.EJ2.Blazor.DropDowns
@using Syncfusion.EJ2.Blazor.Inputs
@using Syncfusion.EJ2.Blazor.PdfViewerServer
<EjsDialog @ref="DialogObj" Width="100%" Height="100%" ShowCloseIcon="true" IsModal="true" @bind-Visible="_dlgVisible">
<DialogTemplates>
<Header>@DialogTitle</Header>
<Content>
<ViewPDF DocumentPath="@DocumentPath"></ViewPDF>
</Content>
</DialogTemplates>
</EjsDialog>
@code {
[Parameter] public AssignmentData AssignmentData { get; set; }
public string DialogTitle { get; set; }
public string DocumentPath { get; set; }
private bool _dlgVisible = false;
protected EjsDialog DialogObj;
[Parameter] public EventCallback OnClose { get; set; }
public void ShowDialog(byte[] pdfData, string dialogTitle)
{
DocumentPath = null;
StateHasChanged();
DialogTitle = dialogTitle;
DocumentPath = "data:application/pdf;base64," + Convert.ToBase64String(pdfData);
StateHasChanged();
DialogObj.Show(true);
}
}
As stated above, this works perfectly fine on my development machine, but throws the JS error when deployed to my web server.