PDA

View Full Version : Speech Bubbles Tooltip - Error Fetching Ajax



sportbiker
08-08-2011, 07:23 PM
Speech Bubbles Tooltip
http://www.dynamicdrive.com/dynamicindex5/speechbubblestooltip.htm

I've successfully installed this script into my site. However, I get an ajax error of "Error fetching Ajax content.<br />Server Response" when someone logs into the site this way:

http://mystore.com
as opposed to
http://www.mystore.com

The error appears in the form of a popup warning window when landing on the homepage.

I'm not sure what options exist for addressing that error, so I'm here and asking! I'm hoping to find a fix that works for both URL options.

Thank you!

djr33
08-09-2011, 12:05 AM
This is blocked by browser security restrictions. You can't load ajax content from any other domain, including different subdomains (such as none and www).

There are a few things you can do:
1. Make sure your users are always on one or the other. This is also somewhat better for search ratings, since you don't have duplicate content.
2. Serve the corresponding page on the same (current) domain. This can be done using relative paths rather than absolute paths. (Use /mypage.htm rather than http://mysite.com/mypage.htm) Alternatively you could dynamically generate the domain for the link (based on the current page) but that would be a lot more work.
3. There are some very complicated ways of at least suggesting that browsers should allow cross-domain content if (and only if) you have access to both domains. But this might also require significant changes to the script. It's very hard, won't be a perfect solution, and probably is not the best choice. (It should be the best choice, but due to the current state of the web, it's impractical.)

ddadmin
08-09-2011, 06:40 AM
The script by default should convert the domain portion of your URL to the speech bubble contents to match the version that the user is currently using to browse the page ("www" or without "www"). How are you specifying this URL inside the script? Something like this?


jQuery(function($){ //on document.ready
//Apply tooltip to links with class="addspeech", plus look inside 'speechdata.txt' for the tooltip markups
$('a.addspeech').speechbubble({url:'http://www.mysite.com/speechdata.txt'})
})

sportbiker
08-09-2011, 05:17 PM
Thank you both for your input. I understand djr33's comments and the rationale behind it. Content is served on the same domain, but I guess according to you, what you're saying is that the www. or http vs. https can affect how the script is processed.

As far as ddadmin states, I am using relative paths and I thought I overcame the issue by using an absolute path, but then when I entered the https portion of my site, the problem was exasperated more, so I went back to relative for the moment but it still gives me that glitch. If you're curious, you can compare the results at:

http://www.ruggedradios.com
and compare to
http://ruggedradios.com


WHAT I'VE ENCODED IN MY PHP HEADER FILE:

<script>
// JavaScript Document
jQuery(function($){ //on document.ready
//Apply tooltip to links with class="addspeech", plus look inside 'speechdata.txt' for the tooltip markups
$('a.addspeech').speechbubble({url:'/Tooltip/speechdata.txt'})
})
</script>


Not being a great coding expert, I'm wondering — would it help to include the actual code contained within "speechbubbles.js" in my header file rather than link to it? Would that help since all processes would be contained in the page rather than linked?

Honestly - thanks for chiming in. It's this kind of help that's so appreciated!

ddadmin
08-10-2011, 06:57 AM
Are you saying when you use the syntax:


$('a.addspeech').speechbubble({url:'http://www.ruggedradios.com/Tooltip/speechdata.txt'})

It fails when the page is accessed as http://ruggedradios.com? Theoretically it shouldn't, since as mentioned, the script should replace the domain portion of the syntax dynamically with the version currently employed by the browser, or http://ruggedradios.com (without the "www"). That then should overcome the Ajax same domain origin issue in such cases.

sportbiker
08-10-2011, 08:28 PM
Just to clear things up in case I mis-spoke, the script for the speech bubbles works (awesome by the way!). It's just that I receive an ajax error message that's only caused when I use this script. I also want to suggest that maybe it's not the script that's in error, but perhaps a combination of this script along with other scripts that's causing the problem. But, when I do delete this script, I don't get the Ajax error; hence my question related to this script.

The error occurs when you visit the site this way:
http://ruggedradios.com
versus visiting the site this way
http://www.ruggedradios.com

If I were to use the full path as you showed, rather than relative, the ajax error manifests again when customers move to the secure "https" checkout portion of my site. For the moment, it's easier to use the relative path, but still, it's a minor error warning I'd like to figure out. If it helps, here's the scripts in my header. Maybe it's a conflict or the order that these are sorted that's adding to the problem:


<script type="text/javascript" src="scripts/jquery.min.js" language="javascript"></script>
<script type="text/javascript" src="/scripts/fadeslideshow.js"></script>
<script type="text/javascript" src="js/prototype.js"language="javascript"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"language="javascript"></script>
<script type="text/javascript" src="js/lightbox.js"language="javascript"></script>
<script type="text/javascript" src="/scripts/swapimage.js"language="javascript"></script>
<script type="text/javascript" src="Tooltip/speechbubbles.js" language="javascript"></script>
<script>
// JavaScript Document
jQuery(function($){ //on document.ready
//Apply tooltip to links with class="addspeech", plus look inside 'speechdata.txt' for the tooltip markups
$('a.addspeech').speechbubble({url:'/Tooltip/speechdata.txt'})
})
</script>