Title: Script not working
Last modified: August 24, 2016

---

# Script not working

 *  [hostmamas](https://wordpress.org/support/users/hostmamas/)
 * (@hostmamas)
 * [11 years ago](https://wordpress.org/support/topic/script-not-working-4/)
 * Hi,
 * I am trying to add the following script into my TEXT editor of wordpress on certain
   pages and it is not working. Any ideas? It works outside of wordpress, but once
   I put the code into a page the button no longer calls to the action.
 * <script src=”//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js”></script
   >
    <input id=”domainname” type=”text” name=”domainname” value=’yournewsite.com’/
   > <input id=”submit-button” type=”submit” value=”Search Domain”> <script type
   =”text/javascript”> var ceURL = ‘[http://www.hostmamas.com/ClientExecutive/&#8217](http://www.hostmamas.com/ClientExecutive/&#8217);;
   var groupId = 2; $(‘#submit-button’).click(function(e) { e.preventDefault(); 
   var fullname = $(‘#domainname’).val(); if ( fullname.indexOf(“.”) == -1 ) { $(‘#
   domainname’).addClass(‘domain_fail’); $(‘#domainname’).val(fullname+’ – not a
   valid domain name’); } else { var name_array = fullname.split(‘.’); $.post(ceURL
   + ‘index.php?fuse=clients&action=checkdomain’, { name: name_array[0], tld: name_array[
   1], group: groupId }, function(response) { console.log(response); if ( response.
   error ) { alert(response.message); } else { var domainStatus = response.search_results.
   status; if ( domainStatus == ‘0’ ) { window.location = ceURL + ‘order.php?step
   =0&productGroup=’ + groupId + ‘&domainName=’ + name_array[0] + ‘&tld=’ + name_array[
   1]; } else if ( domainStatus == ‘1’ ) { window.location = ceURL + ‘order.php?
   step=0&productGroup=’ + groupId + ‘&domainName=’ + name_array[0] + ‘&tld=’ + 
   name_array[1]; } else { alert(‘there was an error, please try again later’); }}},‘
   json’); } return false; }); </script>

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Senff – a11n](https://wordpress.org/support/users/senff/)
 * (@senff)
 * [11 years ago](https://wordpress.org/support/topic/script-not-working-4/#post-6122833)
 * What do you mean exactly by “_It works outside of wordpress_“?
 * When I try this method on my own site, I get this error:
 * > XMLHttpRequest cannot load [http://www.hostmamas.com/ClientExecutive/index.php?fuse=clients&amp](http://www.hostmamas.com/ClientExecutive/index.php?fuse=clients&amp);.
   > No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
   > Origin ‘[http://www.senff.com&#8217](http://www.senff.com&#8217); is therefore
   > not allowed access.
 * Also, you probably shouldn’t have to load another jQuery library at the top of
   the script, since it’s already included in WordPress.
 *  Thread Starter [hostmamas](https://wordpress.org/support/users/hostmamas/)
 * (@hostmamas)
 * [11 years ago](https://wordpress.org/support/topic/script-not-working-4/#post-6122836)
 * Thanks. I guess I should back up and explain better, my apologies.
    I was given
   the code via this link: [http://www.hostmamas.com/domain.html](http://www.hostmamas.com/domain.html)
 * As you can see, if you put a domain in the box (wordpress.com for instance) it
   will take you to the site that offers various other domains available to register.
   So that code is working properly.
 * I viewed the source and copied/pasted the code into my WordPress page Text box
   and it no longer works.
 *  [Senff – a11n](https://wordpress.org/support/users/senff/)
 * (@senff)
 * [11 years ago](https://wordpress.org/support/topic/script-not-working-4/#post-6122840)
 * OK I see. Who gave you that code? Were there any further instructions given?
 * I can’t see what’s not working if I don’t see the actual page where you’re trying
   to include the script, but one thing that’s for sure is that it can only work
   on a page that’s actually part of the hostmamas.com domain. If you try to run
   it on any other site, it will not work.
 *  Thread Starter [hostmamas](https://wordpress.org/support/users/hostmamas/)
 * (@hostmamas)
 * [11 years ago](https://wordpress.org/support/topic/script-not-working-4/#post-6122843)
 * Thanks for your quick response. So I pasted the code and you can see it on my
   homepage at the bottom ([http://www.hostmamas.com/](http://www.hostmamas.com/))
 * I was given the code by the support team at ClientExec whose platform I am using
   for domain registration. He is kind of stumped because he isn’t overly familiar
   w/ WordPress, so I am trying to work through it on my own but, this is a bit 
   beyond my knowledge….
 *  [Senff – a11n](https://wordpress.org/support/users/senff/)
 * (@senff)
 * [11 years ago](https://wordpress.org/support/topic/script-not-working-4/#post-6122850)
 * If you look in your source code, you’ll see that every single line of that script
   starts with a `<P>` and ends with a `</P>`. So I’m not entirely sure what’s going
   on, since you said you entered it in the TEXT mode of the editor.
 * I believe it would be safer to put this directly in the home page PHP template,
   than to put it in the content box.
 *  Thread Starter [hostmamas](https://wordpress.org/support/users/hostmamas/)
 * (@hostmamas)
 * [11 years ago](https://wordpress.org/support/topic/script-not-working-4/#post-6122953)
 * Thanks. I am unsure of which PHP file to add the code into and where to add it
   in the particular file, so I contacted the maker of the theme to inquire. If 
   you have any knowledge in that let me know. Otherwise I will wait to hear back
   from him and see if that solves the problem.
 * Your help is appreciated. Thanks again.
 *  [Senff – a11n](https://wordpress.org/support/users/senff/)
 * (@senff)
 * [11 years ago](https://wordpress.org/support/topic/script-not-working-4/#post-6122992)
 * It’s hard for me to see which template is needed, as I’m not familiar with the
   theme, but it’s possible you’ll have to create a specific home page template (
   front-page.php) and put the code in there.
 * Perhaps it would be beneficial to put it in the footer, but then it would show
   up on every page (unless you put conditional statements around it). I’m not sure
   how technical you are with all this of course!
 * However, let’s see if the theme author can help you directly first.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Script not working’ is closed to new replies.

## Tags

 * [ajax](https://wordpress.org/support/topic-tag/ajax/)
 * [java](https://wordpress.org/support/topic-tag/java/)
 * [programming](https://wordpress.org/support/topic-tag/programming/)
 * [script](https://wordpress.org/support/topic-tag/script/)
 * [text](https://wordpress.org/support/topic-tag/text/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 2 participants
 * Last reply from: [Senff – a11n](https://wordpress.org/support/users/senff/)
 * Last activity: [11 years ago](https://wordpress.org/support/topic/script-not-working-4/#post-6122992)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
