[英]how to pass the ajax Post url with paramters to web service?
actually i have webservice running and i want to retrieve the response or output of web service (xml output) and want to show it on some web page. 实际上,我正在运行Web服务,并且我想检索Web服务的响应或输出(xml输出),并希望在某些网页上显示它。 i am trying to give some parameters as input and sending to webservice by AJAX POST and getting some dummy response.. i have problem while sending the parameters with URL.
我正在尝试提供一些参数作为输入,并通过AJAX POST发送到webservice,并得到一些虚拟响应。我在发送带有URL的参数时遇到问题。 WOULD YOU TELL ME ABOUT THE FORMAT OF AJAX POST PARAMTERS?
您会告诉我有关AJAX后期参数的格式吗?
var params="text=text1&target=target1";
It returns some error value in response, but with the same data i am able to access with the terminal. 作为响应,它返回一些错误值,但使用终端可以访问的数据相同。 text=text1&target=target1 these paramters are passing as one string not different paramters I have tried in other way also
var params='text='+text1+'&target='+target1;
text = text1&target = target1这些参数作为一个字符串传递,与我尝试过的其他参数相同。var
var params='text='+text1+'&target='+target1;
but it returns nothing in response 但它没有返回任何响应
What should I set for params value? 我应该为params值设置什么?
You can't send POST data via url query string. 您无法通过url查询字符串发送POST数据。
You will need to either use cURL
from the command line, or use a POST tool like POSTMAN to pass form data and the appropriate POST headers. 您将需要从命令行使用
cURL
,或使用POSTMAN之类的POST工具来传递表单数据和适当的POST标头。
Edit : your tags suggest you're using javascript/ajax. 编辑 :您的标签建议您使用的是javascript / ajax。
You can do this natively with javascript , but you'd have a significantly easier time using jQuery's $.ajax
or $.post
: 您可以使用javascript本机执行此操作,但是使用jQuery的
$.ajax
或$.post
可以大大简化时间:
$.ajax({
type: "POST",
url: "http://myapp.com/someendpoint",
data: {
text: "text1",
target: "target1"
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.