tags:

views:

29

answers:

1

I have a page that loads a div from another page on successful submission of a form. It works in all browsers except IE 7 and 8 where I get the following error:

Here is the error code: Error: Access Denied

my code:

$("#formTwo").validate({
        groups: { asset: "trade_futures trade_fx trade_equities" },
        errorElement: "em",
        errorPlacement: function(error, element) {
            error.appendTo(element.parent("li"));
        },
        submitHandler: function(form) {
            $("#processing").show();
            var dataString = $(form).serialize();
                $.ajax({
                    type: $(form).attr('method'),
                    url: form.action,
                    data: dataString,
                    success: function(data, status) {
                         $("#currentUser, #newUser, #submitContain, #processing").hide();
                         $("#contain").load('download-download #req');
                    },
                    error: function (data, status) {
                        $("#newUser, #submitContain").hide();
                        $("#contain").html("error");
                    }
                });
            return false;
           },
       //rest of rules and messages

I have seen a lot of discussion about this but none of the solutions seem to work. I have tried loading from google cdn, microsoft cdn, jquery cdn and from a local copy of jquery-1.4.2.js but nothing works!

Is there an alternate way you use to load a div from another page on success?

+1  A: 

The form action you are using to get the url for the ajax method (.load) is that of another domain namely "http://www.ninjatrader-support2.com/sugar/Nt6.5Lead.php.

You cannot do ajax calls cross domain. You are following foul of the same origin policy.

The simplest way to see is open the IE debugging tool and select the script tag and press start debugging. Fill in the form fields and click download, the debugging tool will kick in and show you the following

alt text

Notice the url in the watch window on the right.

redsquare
Except that the OP said this works in all browsers but IE...
Matt Ball
@Matt Ball not all browsers stop you from doing it, however it will not work in ie - http://www.nczonline.net/blog/2010/05/25/cross-domain-ajax-with-cross-origin-resource-sharing/ ....!
redsquare
@redsquare @Matt Ball, i wish I was doing it cross domain, id use cURL and be done with it. This is loading from a page on the same url, i apologize for not being clear
Dirty Bird Design
@Dirty Bird Design, no worries.
redsquare
@redsquare - any ideas how to fix this?
Dirty Bird Design
@Dirty Bird Design does it submit the form?
redsquare
@Matt Ball.....care to add anything else!
redsquare