wp_redirect is only working in Chrome Network, page is not redirecting

167 Views Asked by At

I created a custom WordPress Payment Plugin for WooCommerce, Everything is working fine. When I try to use wp_redirect('url'); page starts to load in Browser Network, but the page is not redirecting it gives me the following error:

SyntaxError: Unexpected token < in JSON at position 0

1

There are 1 best solutions below

0
On
   if (!wp_doing_ajax()) {
          $url = 'https://www.example.com';
          wp_redirect($url);
        exit;
    }

Wrap your redirect if not doing an ajax request.