Retrofit: MalformedJsonException despite right return [duplicate] - json

I use the free webhost 000webhost. The service is okay but it inserts some javascript counter into every file and request.
The script looks like this.
<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script>
<noscript><img src="http://analytics.hosting24.com/count.php" alt="web hosting" /></noscript>
<!-- End Of Analytics Code -->
If i do a jquery post it breaks my code and I get no response.
<?xml version="1.0"?>
<response>
<status>1</status>
<time>1266267386</time>
<message>
<author>test</author>
<text>hallo</text>
</message>
<message>
<author>test</author>
<text>hallo</text>
</message>
<message>
<author>test</author>
<text>hallo</text>
</message>
<message>
<author>test</author>
<text>hallo</text>
</message>
<message>
<author>admin</author>
<text>hallo</text>
</message>
</response>
<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script>
<noscript><img src="http://analytics.hosting24.com/count.php" alt="web hosting" /></noscript>
<!-- End Of Analytics Code -->
How can I fix that? How can I remove the hosting javascript code?

They have a link in their cPanel where you can disable the analytics code.
http://members.000webhost.com/analytics.php
EDIT
Beware - by doing this you violate their policy and they will eventually drop you from their service and you will lose all your data.

In case anyone run into this problem in the future, to stop the analytic code from being included, all you have to do is use the exit() command at the end of your script. The code is in a PHP auto-append file. It doesn't get executed if you exit explicitly instead of letting the script reach the end of the file. The setup at 000webhost.com parses HTML through PHP as well. If you want your regular HTML files to pass validation, add at the very end the following:
<?php exit; ?>

Adding to Catfish's answer,
They have a link in their cPanel where you can disable the analytics code.
http://members.000webhost.com/analytics.php
EDIT
Beware - by doing this you violate their policy and they will eventually drop you from their service and you will lose all your data.
As asked by asalamon74 in the comments,
When I disable the analytics code with this method my domain get canceled due to inactivity. Is there a way to avoid it
Yes, there is a simple way to avoid it. Go ahead and enable your analytics code. Visit http://members.000webhost.com/analytics.php and enable it again.
Then, create a .htaccess in your public_html folder and add the following code to it:
<FilesMatch "\.(php)$">
php_value auto_append_file none
</FilesMatch>
This will prevent all .php files from been appended with the analytics code. Just replace php with any file extension where you want the analytics code removed.
That's all. This way your domain won't get cancelled. Hope it helps.

According to the FAQ, you can go to http://members.000webhost.com/analytics.php to disable the analytics:
How to disable analytic code from my site? (Note: in some case you
might need to add this "php_value auto_append_file none" to your
.htaccess)
FAQ - Frequent Ask Questions Guide!:
http://www.000webhost.com/forum/faq/7894-faq-frequent-ask-questions-guide.html
Alternatively, you could edit your .htaccess file by adding this line:
php_value auto_append_file none

Try changing the content-type in PHP; that should help. (For example, I assume, it doesn't modify images)
Alternatively, you could remove the code in Javascript using indexOf and substring.

Check the terms of service agreement for your host. They may require their analytics code to run unadulterated as part of your TOS.
If they require this code to run, then there are 2 possible solutions:
Get a new host (see http://www.webhostingtalk.com for hosting reviews and deals)
Figure out what in your code is being affected and find a work around there.
If they do not require the analytics code block as a condition of service then you may be able to block their snippet from running by altering the tag's event handler via jquery that they use to fire their code.

If you are using the $.ajax(); function, there is a dataFilter parameter that lets you modify the raw contents of the request before processing it. In here, you could either substring or replace out the offending text, or you could add a <!-- to the end of your XML file, then stick a --> at the end of the response in the dataFilter code.

The analytics code also creates 3 html errors when checked with the w3c validator, so this also lowers your website ranking with google, as google say their ranking also requires that your pages are well formed! try using the validator on this page HERE and you will see the 3 errors.

I had EXACTLY the same problem with these guys. I was so confounded as Chrome just said there was a problem, but thankfully I tried Firefox and it actually blurted out the offending code. I talked to customer support about it, and they said they don't add content to customer pages. Seriously?! So the solution is, as suggested by others, move on and get someone better.

Related

Add link tag using only for homepage in bigcommerce

I want to add <link rel="alternate" href="https://www.example.com" hreflang="en-us" /> this kinda of link tag in my bigcommerce site using jQuery or anything else...
Tried code:
1:
if ($("body#home").length > 0) {
$('head').add($('<link rel="alternate" href="https://www.example.com" hreflang="en-us" />'));
}
2:
var page = window.location.pathname;
if (page == '/' || page == '/index.html') {
$('head').add($('<link rel="alternate" href="https://www.example.com" hreflang="en-us" />'));
}
3:
if ($("html").hasClass("home")) {
$("head").append("<link rel=alternate href=https://www.example.com hreflang=en-us>");
}
But nothing worked for me....
Let's first give some background on hreflang and the three valid ways that Google will read it..
HTML link element in header. In the HTML section of http://www.example.com/, add a link element pointing to the Spanish version of that webpage at http://es.example.com/, like this:
<link rel="alternate" hreflang="es" href="http://es.example.com/" />
HTTP header. If you publish non-HTML files (like PDFs), you can use an HTTP header to indicate a different language version of a URL:
Link: <http://es.example.com/>; rel="alternate"; hreflang="es"
To specify multiple hreflang values in a Link HTTP header, separate the values with commas like so:
Link: <http://es.example.com/>; rel="alternate"; hreflang="es",<http://de.example.com/>; rel="alternate"; hreflang="de"
Sitemap. Instead of using markup, you can submit language version information in a Sitemap.
Source: Google 'hreflang' Usage
So Method 2 isn't possible since you can't modify or control the headers from your BigCommerce store.
This leaves us with Method 1 or Method 3.
The big question here though is..
"Will Google index & process a dynamically inserted JavaScript hreflang link tag"?
Unfortunately at the time of writing this, I need to wait several days for the Google Webmaster Tool to become active on my test site so I can be certain; while all the 3rd party hreflang test sites I used failed. My gut feeling is that I would not trust it. However, if you have an active Google Webmaster / Search Console account, you can test this by going to: Dashboard > Search Traffic > International Targeting.
But for the sake of argument, let's assume that it will work, and so to answer your specific question, you would go about this method like so...
Within the <head>...</head> block, create an empty link tag like so: <link id="lang1" /> This will have the link element physically in the DOM awaiting its attributes to be dynamically added.
Next, immediately below the link element created above, let's create the JavaScript that will turn this empty link tag into a complete hreflang reference depending on the current page:
<script>
// If current page is homepage, then append the neccessary attributes to the link tag. Else, do nothing.
// If on homepage, the link tag would become: "<link id="lang1" rel="alternate" href="https://www.example.com" hreflang="en-us" />"
window.location.pathname == '/' ? $("#lang1").attr({"rel": "alternate", "href": "https://www.example.com", "hreflang": "en-us"}) : false;
</script>
And that's about it from the coding side. If you run this and inspect the DOM (it won't be viewable in page source), you can confirm that your link tag now reads as: <link id="lang1" rel="alternate" href="https://www.example.com" hreflang="en-us" />
Again, whether or not Google will process this, I don't know.
But here's an alternative I do know will work...
We can follow Method 3 listed above, and submit language version information via your site's sitemap, which can specify which individual and specific pages have alternative language versions.
Now, you do not have access to directly modify your BigCommerce generated Sitemap. But what you do have access to, is to:
Create your own custom sitemap file, and upload it to your store.
Tell Google to use the URL of this custom sitemap, rather than the default BigCommerce one.
There are plenty of resources online on how to create a sitemap, and there are many tools that can help automate this process. Although beware, if you use a custom sitemap, then you will need to maintain it and manually update it whenever you add new pages or products to your store.
I've taken the time to point you to some specific documentation resources that should help you with this task. I will eventually come back to this post to transcribe the content from these links into this post as I do recognize posting links is bad SO practice. A hardass might say "well why are you doing it then", and well my time is limited and I'm trying to be as helpful as I can now upfront.
Here is a link from the Google Docs with information on creating a sitemap with page specific language versions.
Here is a link from the BigCommerce Docs with information on uploading a custom file to your store which can then be accessible via your domain/URL.
Finally, here is a link from the BigCommerce Docs with information on how to direct Google to use a specific/alternate file as your store's sitemap.
Please attempt the code suggestion I wrote for Method #1 and test it using your Google Webmaster's tool to let us know if the hreflang link tag is successfully crawled by Google when dynamically inserted via JavaScript - you would be doing the community a great service as there is no definite answer around this.
Remember, you can officially test this by logging into your Google Webmaster Console and navigating to Dashboard > Search Traffic > International Targeting

Need to add the requested URL on a "404"-page. [HTML]

If the user tries to access a page which isn't available, he/she is moved to a custom 404.html.
What I'm wondering is if is it possible to access the original requested URL from the custom 404.html, using just HTML? I haven't used PhP or any other side technology.
My code look like this:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>
If anyone know how do this, please let me know. Thank you in advance!
Long story short, answer to your question: no, it is not possible to get url by using HTML ONLY, you need to either use client side or server side language.
for example, in javascript, you would do something like this to get previous url,
document.referrer
this would actually be ideal for your scenario, as this work very well, if you arrived at the current page via a link ( not by doing, for example, by bookmark or typing in the address bar).

Using anchor tag to open a mailto and invoke a URL

With one of my requirements i need to open up the default mailing client with invoking a call to a service, this needs to be accomplished using anchor tags or purely html, the constraint is that we can not use javascript for the same.
Does anyone have any idea on how to accomplish this?
try this:
Click to Mail
This will open default mailing client.
Edit :
You may use onClick function to open new window and call you webservice url in it.like
Click to Mail
you can use like this
<a href="mailto:me#domain.com?subject=Call me&body=dummy mail:">
touch here</a>
try it
If you feel very very daring (and don't mind a horrible hack), you can try if
<meta http-equiv="refresh" content="1; url=mailto:foo#bar.baz" />
on your service page helps you. My brief check in FF suggests that since the new target starts an external program, the page doesn't go elsewhere. This might require some reshuffling of your service, depending on where exactly you want to spawn the mail window.

Javascript of external iwidget on IBM Connections 4 is retrieved but the events (onView) are not fired

I have an iWidget that is deployed outside the Connections environment.
This iWidget is working in WebSphere Portal 8, the iWidget Wrapper.
The iWidget can be added to a community and the initial text is loaded.
The onView() or other events are never invoked, resulting in the iWidget displaying the initial message and the 'div' never being replaced. I have change the src of the javascript in different ways, the ./javascript one, being the latest.
Firebug shows a succesful retrieval of the js (widget.xml) through the communities/proxy context root.
This is the iWidget XML:
<iw:iwidget id="365DocsWidget" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:iw="http://www.ibm.com/xmlns/prod/iWidget" supportedModes="view edit" mode="view" lang="en" iScope="365DocsWidgetScope" sandbox="false" allowInstanceContent="true"><iw:itemSet id="pref"><iw:item id="documentlist" value="https://fire3ice.sharepoint.com/sites/demo4if/_api/Web/Lists(guid'cca56100-1f15-461b-92f3-d1da80ba1ca8')"/></iw:itemSet><iw:resource src="./javascript/365DocsWidget.js" /> <iw:content mode="view"><![CDATA[<div id="ROOT_DIV">Hello World, last time this widget was updated: 2013-01-04 16:07:17</div>]]></iw:content><iw:content mode="edit"><![CDATA[<div id="EDITMODE_DIV">Hello Edit World</div><div><input type="button" name="selectDocumentList" value="selectDocumentList" onclick="iContext.iScope().changeDocumentList()" /> </div> ]]></iw:content></iw:iwidget>
The widget.xml is publically accessible here:
https://eog-fire-ice.appspot.com/365DocsWidget.jsp
This might be caused by the Javascript resource for the iWidget not being recognised as Javascript and therefore not being loaded.
Can you set a Content-Type of application/javascript on the response for the JS file?
I've also seen this when I have a typo in the JavaScript file. Please go through the JavaScript file and make sure there are no missing commas or semi-colons.
There is a mismatch between your xml and js.
The iScope in your xml is "365DocsWidgetScope"
The Object declared in your js is "J365DocsWidgetScope" (in https://eog-fire-ice.appspot.com/javascript/365DocsWidget.js)
replace "J365DocsWidgetScope" to "365DocsWidgetScope" should be able to solve the problem.

Using SSI in HTMLs imported using c:import in jsps

I have a bunch of htmls in the webserver context (outside the application context) in the htdocs area. These htmls use SSI to call other htmls.
Here's the problem:
When I use c:import to call the main html into the jsp, the secondary htmls inside the main html don't render / are not processed.
Is there a way to get the main html to "compile" and then return to the jsp?
JSP codes:
<c:import url="<%=/folder/Header.html%>"
HTML server side logic that needs to be processed:
<!--#include virtual="/abc/xyz.html" -->
<!--#if expr='"$Category" = "someCategory"' -->
<!--#echo var="pageTitle" -->
The prototypes were given as all htmls, so everything was in the web context and all files worked fine. The issue is moving the top layer to JSP and keeping the rest of the layers as HTML. (Its a requirement)
Any solutions /thoughts/ ideas would be welcome! Thanks for your asssistance!
Wave
EDIT: Ok, I'm getting the Header.html in an iFrame because that will initiate a new HTTP request (and thus have access to the SSI logic).
<iframe id="testSSI" src ="http://somesite.com/subfolder/testssi_1.html?pageTitle=Applications" frameborder="0" width="800px" height="300"></iframe>
The parameters are sent in the URL and I've managed to extract the control parameters using js.
My query has reduced to this:
How can I access this js value "Applications" in the SSI logic? Is it possible to set is as an environment variable? That could be pulled by the SSI logic.. I realise that the Js will run after the SSI is done, but hoping someone here would be able to help.
Thanks!
Thanks, got it done.
I accessed the parameter in SSI by using the QUERY_STRING environment variable.
Example of html call:
http://somesite.com/subfolder/testssi_1.html?Applications
Example of how i retrieved the value:
<!--#set var="pageTitle" value="$QUERY_STRING" -->
<!--#if expr=" ${pageTitle} = Program " -->
do something
<!--#else -->
do something else
<!--#endif -->
The objective here:
We use a JAVA framework. But Marketing wanted content to be editable by them in a separate process.This way, they can change the content frequently with out the intervention on the jsp / java team. (Eg. change header look and feel, add new links, etc)
Hope this helps someone out later. :)
Wave
Edit: In the example above -> "Applications" will take the logic to the else section..
In addition, to send name value pairs:
http://somesite.com/subfolder/testssi_1.html?name=Applications&app=Demo
you can reference them as:
<!--#if expr=" ${QUERY_STRING} = /name=Applications/ " -->
AND
<!--#if expr=" ${QUERY_STRING} = /app=Demo/ " -->