javascript - Using XMLHttpRequest with username and password -
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <head> <script> jquery.noconflict(); jquery(document).ready(function() { alert("hello world, part 2!"); callotherdomain(); }); function callotherdomain() { var invocation = new xmlhttprequest(); var username = "testuser"; var password = "testpass"; var url = 'http://someurl'; invocation.withcredentials = true; invocation.open('get', url, true); invocation.send(); } </script> </head>
i need pass username , password access link. not sure how it. glad if here can help!
the same doing using ajax, need use xhttprequest implement cors.
function getcontacts () { jquery.ajax({ type: "get", url: "http://some", contenttype: "application/json; charset=utf-8", datatype: "json", username : "some", password : "some", success: function() { alert('get completed'); } }); }
Comments
Post a Comment