Hide the url username and password from client script

Get the field value of another field by using the API
for this I have wrote a function in client in client side

function statename(){
$.ajax({
			url: myurl to get the statename,
			type: "GET",
			dataType: 'json',
			success: function (data, textStatus, jqXHR) {
				$("#state").val(data);
			},
			error: function (jqXHR, textStatus, errorThrown) {
				alert('error')
			}
		});
}

here the code is working and I got the statename and it is automatically set to the another field.
in the client script the url content with the username and password.
So any body can see the url use in the client side.How can I hide this url with username and password.

Why do you pass the user name and password in the URL? If you must, you better pass by HTTP POST.

the url is the external url
API from other websiteI need to run in java script as it should effect the another field.

Then you need to check the spec of the your external API and see how they accept the user name and password.