1

My site is http://www.tripconnects.com. I am trying to create a login process in which when a user logs into my site, it will be logged into a third site also. I am using jquery submit() function to submit the form for authentication on third site. But when the submit event is fired it tries to open a popup. I've added the target="_blank" attribute to form also, but nothing seems to work. Here is my jQuery code :

$(window).load(function(){
    if ($(".adlogin .readon .button").length == 1) {
        $.ajax({
            url : '/adlogin_ajax.php',
            method : 'post',
            success : function(response){
                if(response == 'true'){
                    $("#ssoform").submit();
                }
                return false;
             }
        }); 
    }  
});

Please Help. Thanks!

Drachenfels
  • 3,037
  • 2
  • 32
  • 47
shalini
  • 135
  • 3
  • 16

1 Answers1

0

If I understand correctly you are want to do following:

As user logs in on your site you want to fill login form on the other site with credentials provided on yours and press submit.

What you doing right now is to using ajax, get content of target site, and submit form. This will trigger new popup/tab with answer from that site.

Solution.

First check where the form on target site is pointing you. After pressing submit there is some kind of url (intercept that url in console/terminal in google chrome or firefox).

Then to something like:

$.post("<interecepted_url.php>", {login: "mylogin", password: "mypass"})
.done(function() {
   alert( "second success" )
})
.fail(function() {
   alert( "error" )
})
.always(function() {
   alert( "finished" )
})

However this solution is a bit hackish, because you are making cross domain requests, it may be over ssl, csrf protection that sort of the problem. Nevertheless sometimes man has to do what man has to do. ;)

In general what you want to do is not open some kind of site, find a form and submit it, but pretend to be that site, forge a request and post it, receive the answer and process that answer on your site.

Let me know, if it helps.

Drachenfels
  • 3,037
  • 2
  • 32
  • 47