GoDaddy DNS Preview breaks Javascript and jQuery

A client of mine is redesigning a website and I’m helping out with the PHP and Javascript. The client is using GoDaddy to host the site and because the current site is still live, we have to use GoDaddy’s PreviewDNS in order to test the new site. I started coding some basic jQuery and this is where it got weird.

I was trying to do some really basic stuff like submit form and do ajax calls, but none it was working at all. Here’s an example:

[pre lang=’javascript’]
$(document).ready(function(){

$(“#checkbox”).click(function(){

$.ajax({

type: “POST”,
url: “ajax/testing.php”,
data: “var1=” + $(“#var1”).val() + “&var2=” + $(“#var2”).val(),
success: function(msg){ alert(msg);},
dataType: “text”,
error: function(msg){ alert(msg);}
});
});
});
[/pre]

So I just wanted a really basic ajax call. The Safari inspector was giving this error: “TypeError: Result of expression ‘$(“#checkbox”).click’ [undefined] is not a function.” I thought this was really weird. I hadn’t coded jQuery in a while so I thought I might just be doing something wrong. Turns out I wasn’t. I tested this same code on my own server and it worked perfectly.

I check google to see if others were having issues but this was the only post I came across. I figured there would be more feedback about it.

So the GoDaddy PreviewDNS feature seems to break jQuery somehow. I checked out the source of the pages and there is a bunch of CSS and Javascript the PreviewDNS adds into the bottom of the page. Take a look:

[pre lang=’javascript’]


[/pre]
[pre lang=”html”]


[/pre]
[pre lang=”javascript”]



[/pre]

So if anyone is thinking of using GoDaddy’s PreviewDNS to test a site, save yourself the headaches and time and just buy an ip to test from. For that matter, just stay away from GoDaddy. I really haven’t heard anything good about them.

[carousel keywords=”javascript, jquery” category=”Books” tag=”damnsemi01-20″ showBorder=”True”]

Continue Reading

  • Anonymous

    Ran into a similar issue.

    In Drupal 6 running on a GoDaddy server I was not able to update a page which included JavaScript cookie code while using previewdns. I could submit the line of code on a normal domain and I could literally change one character and have it work on previewdns but when the code included “document.cookie” the page would not update. It would eventually time out and redirect to a page saying the previewdns is not set up for that site. I ended up just dropping the code directly in the MySQL database instead which worked around the issue. The previewdns feature is actually really useful and if GoDaddy didn’t insert all the extra crap in there I wouldn’t have a beef with it.

    • Skye

      ya I’m not sure if they have to add in all that extra garbage to make it work. it was somewhat useful but there is definitely better ways for testing a new site before changing the dns. it could be the only way if you’re using godaddy’s cheapest hosting package. I’m not too familiar with the options the offer.