Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6576091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:28:05+00:00 2026-05-25T15:28:05+00:00

I have a piece of Javascript I want to run when a form loads.

  • 0

I have a piece of Javascript I want to run when a form loads. The form handles itself. When the form loads the Javascript works great, but when the form is submitted and the page handles itself the Javascript breaks it.

Is there a way to make the Javascript only run when the form is not being handled?

UPDATE:

I get this error when the form is handled (the Javascript is doing a AJAX request):

TypeError: ‘undefined’ is not an object
XMLHttpRequest cannot load [ajax request url] Origin [original page] is not allowed by Access-Control-Allow-Origin

Here is the HTML:

<form method="#" action="post">
    <!--form elements-->
</form>

Here is the Javascript:

ajax.onreadystatechange=function() {
    if (ajax.readyState==4 && ajax.status==200) {
        document.getElementById("invitestar-message").innerHTML=ajax.responseText;
        var signup = document.getElementById("invitestar-content-container");
        setTimeout(function(){
            body.removeChild(document.getElementById('invitestar-verifying'));
            signup.style.display = "block";
        }, 500);
    }
}

ajax.open("GET","http://nvrforget.com/invitestar/check-invite/?invite=kNdqyJTjcf",true);
ajax.send();

The domain that this javascript is run on is not http://nvrforget.com/.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:28:06+00:00Added an answer on May 25, 2026 at 3:28 pm

    This error:

    XMLHttpRequest cannot load [ajax request url] Origin [original page] is not allowed by Access-Control-Allow-Origin
    

    is caused because you can’t make ajax calls to a different domain than the web page is located on. See this description of the same-origin policy.

    JSONP is a way to make cross-origin ajax calls. It requires a cooperating server (to implement the server side of the JSONP) and a method of adding the ajax request as a script tag. Libraries like jQuery or YUI support the client-side parts of JSONP or you can do it yourself (but you still need a cooperating server). Google JSONP if you want to know more about it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small piece of javascript that I would like to use but
I have a piece of javascript code like this right now. document.getElementById(pos).style.backgroundColor='#800080'; I want
I have a piece of javascript code that I want to execute on the
I have a piece of JavaScript that's part of a library that I want
I have this piece of Javascript and it just won't work. I allready checked
I have a piece of Javascript that checks for a condition (via an AJAX
I have a piece of javascript code as follows: var data = { ...
HI All, I have a piece of javaScript that removes commas from a provided
Have the following piece of javascript over on http://jsfiddle.net/mhenrixon/zPLgS/16/ and its working fine in
I have this piece of code in javascript: var catId = $.getURLParam(category); In my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.