: AJAX compatibilty In 2015 Google stopped supporting their AJAX for Adsense program, So I've researched and developed tons of AJAX content. I understand the flaws so I'm striving for backwards
In 2015 Google stopped supporting their AJAX for Adsense program, So I've researched and developed tons of AJAX content. I understand the flaws so I'm striving for backwards compatibility.
loadPage('https://www.example.com/home');
function loadPage(){
customRequest('/php/homepage.php', {one:'var1', two:'var2' }).promise().done(function(data,status,err){
$(getElementById('home')).html(data.html);
});
}
function customRequest(u,d) {
var promise = $.ajax({ type: 'POST', dataType: 'JSON', data: d, url: u })
.done(function (responseData, status, xhr) { console.log(responseData); })
.fail(function (xhr, status, err) { console.log(xhr); });
return promise;
}
Relying on AJAX, my web-app never reloads. I have a function that is built for loading pages into the proper container, much like a modern-app with touch-based input such as SnapChat.
The problem manifests with the 'Fetch as Google' tool, as it does not scan the dynamic content. By changing the DirectoryIndex .html to DirectoryIndex .php in the .htaccess I'll be able to get rid of the first line
loadPage('https://www.example.com/home');
and handle the initial load with the php file. Is this a really a viable solution or would I still not be able to load the ads in the dynamic content. There's not really any official answer, just several unanswered questions.
More posts by @Martha676
1 Comments
Sorted by latest first Latest Oldest Best
Does it really make sense to rely on AJAX in conjunction with a server-side language like PHP to serve content?
It really depends what you are trying to do. If you plan to make a page of a bunch of short stories, then plain-old HTML will work just fine. Heck, you could even get away without using CSS for stories, but then again, if you want the text somewhat prettier and/or fancier, thats where CSS comes in.
If your site involves submitting something to the server to get a small response back (for example, clicking a submit button on a quiz only to find out if your answer is right or wrong), then ajax will do just fine since then the user doesn't leave the page and a message will appear. As an alternative (especially if Google does cut AJAX scanning for good), you can go super-old-fashioned by creating a simple HTML form and when a user submits something (such as the quiz answer), a separate page loads (via server script aka php file) that tells the user whether he is right or wrong.
But before assuming Google can't handle ajax, you might want to try making all javascript internal to the page (meaning don't use this syntax in your HTML: <script type="text/javascript" src="http://example.com/external.js">). That way when Google scans the page, it won't have to try to load external resources that it may not have permission to access (depending on your server settings).
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.