Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

426
Views
PayPal button SDK function does not found it's script when called in Blazor

I have a blazor app, and I'm trying to implement PayPal purchase button. It generates the button but it does not work. When pressed and inspected the console says that

Uncaught Error: Document is ready and element #paypal-button-container does not exist

The script for the Paypal button is in wwwroot folder, in javascript file. The function of the script is being called in the blazor component page Index.razor

@page "/"
@inject IJSRuntime JS
@inject AuthenticationStateProvider AuthenticationStateProvider
@using LoginComponent
@using Client.Data
<AuthorizeView>
    <Authorized>
        Hi, @context.User.Identity.Name
        <div id="paypal-button-container"></div>
    </Authorized>
    <NotAuthorized>
        <Login/>
    </NotAuthorized>
</AuthorizeView>


@code
{
    double a = 9.99;

    protected override async Task OnInitializedAsync()
    {
        
    }

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            await JS.InvokeVoidAsync("LoadButtonPaypal", a);
        }
    }
}

Inspect element error:

Uncaught Error: Document is ready and element #paypal-button-container does not exist
    at js?client-id=test:2
    at new n (js?client-id=test:2)
    at Ce (js?client-id=test:2)
    at js?client-id=test:2
    at Function.n.try (js?client-id=test:2)
    at fn (js?client-id=test:2)
    at js?client-id=test:2
    at Function.n.try (js?client-id=test:2)
    at Object.render (js?client-id=test:2)
    at js?client-id=test:2

Why does it not find the #paypal-button-container? Or is this not the problem why is it not working

Here is the script for the button from The PayPal website.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!