Javascript RESTAPI使用jquery获取调用

Javascript RESTAPI使用jquery获取调用,javascript,jquery,Javascript,Jquery,我正在尝试使用jqueryajax使用restapi,我在这样做时遇到了问题 我的api是http://183.11.23/Kapture/Service1.svc/LoginVerification/abc@outlook.com/123 我的Html文件 <!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Insert title here</tit

我正在尝试使用jqueryajax使用restapi,我在这样做时遇到了问题 我的api是
http://183.11.23/Kapture/Service1.svc/LoginVerification/abc@outlook.com/123

我的Html文件

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>


<script src="http://code.jquery.com/jquery-2.2.0.min.js"></script>

<script src="login.js"></script>

</head>
<body>
<div>
<form onsubmit="login()">
email:<input type="email" name="email" id="emailId"></br>
password:<input type="password" name="password" id="password">
<button type="submit" name="submit" >submit</button>
</form></div>
</body>
</html>

请帮助我

您应该更新您的服务以使用其中的请求参数,而不是以“用户名/密码”的方式传递它们 您可以将它们作为参数传递到函数中的url中,虽然这不是最好的方法,但您还没有发布您的服务方法,您应该将其作为更好的方法

"http://183.11.23/Kapture/Service1.svc/LoginVerification?username=someuser&password=somepassword"
Javascript:

function login(){

    var myusername = $("#emailId").val();
    var password = $("#password").val();
    $.ajax({
      type: "GET",
      url: "http://183.11.23/Kapture/Service1.svc/LoginVerification?username=" + myusername +"&password="+password,

      cache: false,
      success: function(data){
         $("#resultarea").text(data);
      }
    });
}
在后端,您应该有类似

  String username = Request.Querystring["username"];
  String password = Request.Querystring["password"];

183.11.23
-不,这不是您服务的IP号码,它是无效的。插入真实的IP号码并重试。跨域无法使用jquery,buuuttt:Hi@JohannesJander我没有给出完整的url出于安全原因,它是虚拟的。那么您面临的问题是什么?你的问题是什么?什么不起作用?你会期待什么?实际发生了什么?您看到了哪些错误?请提供详细信息。听着,我不会为你写代码的。查看如何对参数进行URL编码,然后使用下面的答案,但添加URL编码的参数,而不是未编码的参数。这样做很糟糕,如果用户名包含“some/username”,它将无法逃避类似
/
我不懂这不是通过querystring传递吗?如果在ajax调用的数据属性中设置json值。。。jQuery不是在url中为您编码键值对吗?
  String username = Request.Querystring["username"];
  String password = Request.Querystring["password"];