batman_man
batman_man

Reputation: 15

Help submitting an asp.net form with jquery

I'm trying to post the entire asp.net form to a certain url.

I have tried:

$.post("http://www.someaddress.com", $("form").serialize());

I have also tried:

$.ajax({
    type:"POST",
    url:"http://www.someaddress.com",
    data: $('form').serialize(),
    success: function(){
        alert('yay');
    }
});

In both cases the submit is fine but no data is passed along with it.

When i test the form.serialize() in firebug console, this shows my form serialized just fine. When i view the submit in fiddler, i can see that the data part is not set. Maybe im not understanding the data part, but every single tutorial shows this as the way to go -> serialize the form and set that as data. What must i do to get my serialized form as the data in my request?

What am i missing? Also - why does the NET tab in firebug show all these requests as method OPTIONS?

Upvotes: 1

Views: 141

Answers (2)

sushil bharwani
sushil bharwani

Reputation: 30187

You cannot do a Ajax request to a foreign domain. As this is not allowed (against security) in javascript to access a foreign page ( not on your domain )

Upvotes: 0

jAndy
jAndy

Reputation: 235992

is this

url:"http://www.someaddress.com"

just an example or do you try to access a foreign domain? (which would explain the problem).

Based on your comment, the ajax same origin policy does not allow to access a foreign domain.

Upvotes: 1

Related Questions