Jump to content

When using JS fetch() it seems (!$config->ajax) is ignored


a-ok
 Share

Recommended Posts

Quick one.

When using JS fetch() rather than jQuery's $.ajax, in my templates

if (!$config->ajax) include $config->paths->templates . "head.inc";

 seems to be ignored and it returns the head.inc in the response.

Am I missing something?

Link to comment
Share on other sites

2 hours ago, Mats said:

Check this: 

 

Many thanks for this, @Mats

var request = new Request(url, {
	headers: new Headers({
		'X-Requested-With': 'XMLHttpRequest'
	})
});
fetch(request)
.then(response => response.text())
.then(data => {
	console.log(data);
});

 

  • Like 6
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...