I am trying to fake a bypass of basic browser authentication, and I really don't understand how this works.
I have seen people cope with this basic authentication.
Basically, the browser asks me to enter the username and password at the very beginning, but I want it to wait while the user enters the username and password in <form>...</form> .
I am really trying to request some JSON files.
I saw people using xhr.setRequestHeader and / or ajax {method: GET} , but so far nothing has worked for me.
How does it really work and in what order?
Ok, I found the answer using the arm. The "PUT" command is for changing something. The "POST" command is designed to create / add something:
var mydata = {"fname":"bobworth"}; $.ajax({ type: "PUT", processData : false, data: JSON.stringify(mydata), dataType: "json", url: "http://www.example.com/users/", contentType: "application/json; charset=utf-8", username: "mark", password: "123456", success: function(t){ alert(t); }, error: function(jqXHR, textStatus, error){ alert("jqXHR:"+jqXHR.status+" txtStatus:"+textStatus+" Error:"+error); } });
source share