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 7410207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:12:04+00:00 2026-05-29T06:12:04+00:00

Here is my HTML. Just a simple form: <form> Username: <input type=text id=username/> <br/>

  • 0

Here is my HTML. Just a simple form:

<form>
    Username:
    <input type="text" id="username"/>
    <br/>
    Password:
    <input type="password" id="password"/>
    <br/>
    <input type="submit" id="submit" value="submit"/>
</form>

Here is my JS associated with it:

function init(){
$("#submit").click(function() {   
    var url = "http:example.com/mail";
    alert("what?");
    $.ajax(url, {
        type : 'post',
        data : {
            'username' : $("#username").val(),
            'password' : $("#password").val()
        },
        success : function() {
            alert("done");
        }
    });
});
}

After I clicked on the submit button, the $.ajax function is supposed to do a post to the URL where I keeps my server running.

However, from my server side log or firebug network monitoring, I didn’t see any sign of the POST method. (The first alert was triggered but the second wasn’t.)

They are two different applications that I developed, so after I did some research, here is one explanation:

Since $.ajax() uses XMLHttpRequest, it is subject to XHR’s cross-domain restriction. Are your SiteA and SiteB on different hosts/ports? If so, you’re seeing the expected behavior.

Is that so? If so, is there any workaround?

  • 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-29T06:12:05+00:00Added an answer on May 29, 2026 at 6:12 am

    You need return false; at the end of the click handler to prevent the default submission of the form. Although once you prevent the form from submitting, you will still have the cross-domain restriction, which is not trivial to solve. Look into jsonp for a possible solution.

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

Sidebar

Related Questions

I have a simple html input textbox in a very simple form. the information
I have a simple form with just one textbox and one submit button. The
A simplified version of problem I am experiencing: Here is my HTML form: <form
Here is the input (html, not xml): ... html content ... <tag1> content for
I've got a simple form on a webpage (that doesn't actually submit any info),
I'd like to use Silex's service providers just to build a simple contact form
I have a simple html login form, deployed on Xcode using phonegap framework. When
Right now I have simple form with a single input. I'm trying to use
I’m just starting to explore asp mvc and jquery. I have a simple form
Hi I have a simple form that allows a user to input a name,

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.