1

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?

0

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

im definitely trying to access a foreign domain - and yes its an example
ah ok - could you explain to me how/why this works when i put an asp button on my page and set a postbackurl to a foreign domain? i basicly want to achieve the same without the redirect..
basically, impossible. Do you have access to the foreign domain ? If so you may use jsonp to transfer data.
0

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 )

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.