tags:

views:

48

answers:

1

Hi, I have a form which on submit I want to run a script via Ajax, but for some reason it is returning an error. Any idea what is wrong? My code is as following:

$('.spiderform').submit(function (event) {
        event.preventDefault();
        alert($(this).serialize());
        $.ajax({
            type: 'get',
            url: 'http://spidertest.epiphanydev1.co.uk/spider/?'+$(this).serialize(),
            beforeSend: function() {
                alert('sending form');
            },
            success: function() {
                alert('worked');
            },
            error: function(jon) {
                alert('error');
            }
        });
    });

Thanks

+4  A: 

Since you haven't given any idea what error is is, but since you have an absolute URI in there, I'd guess you are running into the Same Origin Policy.

David Dorward
Thanks for your response, Yes the URL i'm sending to is on a different server than the one I'm making the call from. How would I achieve the results I'm after?
Probocop
Probocop, submit it server-side. Your ajax submit it to php/servlet/cgi, and then php/servlet submit it to the intended server.
Rosdi
That's exactly what I've just ended up doing :)
Probocop