Link to home
Start Free TrialLog in
Avatar of yahoolane
yahoolane

asked on

Jquery post, test return data

This is mostly from the Jquery post example from the jquery site.
My goal is to send the login to the site, see what the results are.
if the results are what I want
I will post the data again and let it be redirected to the correct site.

First, I can not tell if it is even firing, I put a alert in the data but it did
not fire,
I would like to see the resuts and then be able to test some of the data.

Can someone see what I may have done wrong here ,and tell me how to
get the resulting and move forward.
<!DOCTYPE html> 
<html> 
<head> 
  <script src="http://code.jquery.com/jquery-latest.js"></script> 
</head> 
<body> 
<form action="http://brain.com/default.asp" id="Form1" >
   
username   <input type="text" name="username"  id="username" /><br /> 
password    <input type="text" name="password"  id="password"   /> <br />
   <input type="hidden" name="institution" value="brain"  id="institution" /> 
   
   make a graph <input type="submit" name="submit"  /> 
  </form> 
  <!-- the result of the search will be rendered inside this div --> 
  <div id="result"></div> 
 
<script> 
  /* attach a submit handler to the form */ 
  $("#Form1").submit(function(event) { 
 
    /* stop form from submitting normally */ 
    event.preventDefault();  
         
    /* get some values from elements on the page: */ 
    var $form = $( this ), 
        username = $form.find( 'input[name="username"]' ).val(),
        password = $form.find( 'input[name="password"]' ).val(),
        institution = $form.find( 'input[name="institution"]' ).val(),
        url = $form.attr( 'action' ); 
 
    /* Send the data using post and put the results in a div */ 
    $.post( url, { username: username , password:password, institution:institution  }, 

      function( data ) { 
            var content = $( data ).text()
         $( "#result" ).empty().append( content ); 
        // Experts-Exchange:
        // What  I want to do here is 
        // get the contents of results test them and 
        // post the data to another site and go there. 
      
      } 
      ); // post 
  }); 
</script> 
 
</body> 
</html>

Open in new window

Avatar of leakim971
leakim971
Flag of Guadeloupe image

could you confirm your page is on the same domain and protocol than the action url?
http://brain.com/default.asp
Avatar of yahoolane
yahoolane

ASKER

The are on different domains.

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Both are good results.