You might wanna use firebug and make sure your getting a correct response.
It might be making an error because what you are assigning isnt a url.

On 7/5/07, Mike Fern <[EMAIL PROTECTED]> wrote:


hi devs,
i'm new to this group. i recently play with jquery and feel happy with
the features and simplicity offered.

however, i stumble upon a problem with redirecting url using jquery.
this is my code:

//Start the ajax call
var $vc = jQuery.noConflict();
$vc(document).ready(function() {
        $vc("#vcform").submit(function() {
                var inputs = [];
                $vc(':input', this).each(function() {
                        inputs.push(this.name + '=' + escape(this.value));
                })

                $vc.ajax({
                        type: 'GET',
                        data: inputs.join('&'),
            url: "http://localhost:8282/rpc.php";,
            timeout: 1000,
            error: function() {
                                alert("Failed to submit or response
error");
                        },
                        success: function(r) {
                                //redirUrl = r;
                                location.href=r;
                        }
                });
                return false;
        });

});

the ajax call is used to get url from rpc.php and then redirect the
page according to response url given by rpc.php.
whenever i submit my form, i always get the alert message. i have done
investigation that the error is caused by this line "location.href=r;"

anybody ever experienced this issue?

in native ajax call, i can do this by just simply using this code:
function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function sendVcRequest() {
        var param = 'vctype=' + document.getElementById('vctype').value +
'&vcnations=' + document.getElementById('vcnations').value;
    http.open('get', 'http://localhost:8282/rpc.php?' + param);
    http.onreadystatechange = redirectUser;
    http.send(null);
}

function redirectUser() {
    if(http.readyState == 4){
        var res = http.responseText;
        location.href= res;
    }
}

thanks before


Reply via email to