• 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 = ‘https://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)
  • 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 https://www.hostmamas.com/ClientExecutive/index.php?fuse=clients&amp;. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘https://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

    (@hostmamas)

    Thanks. I guess I should back up and explain better, my apologies.
    I was given the code via this link: https://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.

    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

    (@hostmamas)

    Thanks for your quick response. So I pasted the code and you can see it on my homepage at the bottom (https://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….

    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

    (@hostmamas)

    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.

    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.