Guest User

Untitled

a guest
Jun 28th, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. $("#getSomethingButton").click(function () {
  2. var username = "myusername";
  3. var password = "mypassword";
  4. $.ajax({
  5. url: 'people/getSomething',
  6. username: username,
  7. password: password,
  8. dataType: 'jsonp',
  9. jsonpCallback: 'onGetSomething'
  10. });
  11. });
  12.  
  13. public string GetSomething(string callback)
  14. {
  15. string data = "{data: 'test'}";
  16. return string.Format("{0}({1});", callback, data);
  17. }
  18.  
  19. // Obviously the username/password should not be hardcoded but read from an input
  20. $.get('/home/foo', { username: 'foo', password: 'secret' }, function(result) {
  21. alert('username/password sent');
  22. });
  23.  
  24. public ActionResult Foo(string username, string password)
  25. {
  26. ..
  27. }
Add Comment
Please, Sign In to add comment