通过ajax向第三方API发送https请求 [英] https request with ajax for third party API
问题描述
朋友,
我真的很感谢任何建议!
以下是我用来进行API调用的代码,它无法正常工作.
实际上ajax部分不起作用
Hi Friends,
I would really appreciate for any kind of advice!!
Below is a code I am using to make an API call and its not working properly.
Actually the ajax part is not working
$('#mainContainerMainPage').append('<li class="listitem"> <p class="paddtittle"><a href="https://a2atest.wildcardsystems.com/a2a/CO_LoadValue.asp?userid=xxxxxx&pwd=xxxxx&sourceid=xx&cardnum=xxxxxxxx&purseno=14&amount=10&resp=html"> Confirm Load Value </a> </p></li>');
上面的几行效果很好,它是动态创建html元素,并创建了一个带有heref链接的html元素,按下该链接时会进行API调用
并且我得到的响应是html或xml格式,但问题是我无法抓取响应并以自定义格式显示该响应.因此,我尝试了另一种方式,即对api调用进行ajax调用以获取响应并进一步使用,但是它无法正常工作,没有响应,我不知道我做错了什么还是有其他处理方法.您能帮我打一个正确的Ajax电话并获取结果吗?.
代码从这里开始
above lines works fine what it does is to make a html element dynamically and it creates a an html element with heref link which is when pressed makes an API call
and the response I get is in html or xml format but the problem is I cannot grab the response and show that in a customized format. so I tried another way which is ajax call for the api call to grab the response and use further but its not working no response I don''t know if I am doing some thing wrong or there is some other way of doing it. Can you help me make a proper ajax call and grab the results?.
Code starts here
$(document).ready(function() {
$('#makecall').click( function() {
$('#mainContainerMainPage').append('<li class="listitem"> <p class="paddtittle"><a href="https://a2atest.wildcardsystems.com/a2a/CO_LoadValue.asp?userid=xxxxxx&pwd=xxxxx&sourceid=xx&cardnum=xxxxxxxx&purseno=14&amount=10&resp=html"> Confirm Load Value </a> </p></li>');
$.ajax(
{
url:'https://a2atest.wildcardsystems.com/a2a/CO_LoadValue.asp?',
type:'POST',
data: {userid:'xxxxxxxx', &pwd:'xxxxxxx',&sourceid:'xx',&cardnum:'xxxxxxxxx',&purseno:'14',&amount:'10',&resp:'html'},
success: function(data)
{
$('#mainContainerMainPage').append(data);},
error: function(data)
{
$('#mainContainerMainPage').append(data);}
});
});
谢谢!在Advance
Thanks! in Advance
推荐答案
('#mainContainerMainPage').append('< class = " > >< p 类 =" > < =" < /a > < /p > < > ');
('#mainContainerMainPage').append('<li class="listitem"> <p class="paddtittle"><a href="https://a2atest.wildcardsystems.com/a2a/CO_LoadValue.asp?userid=xxxxxx&pwd=xxxxx&sourceid=xx&cardnum=xxxxxxxx&purseno=14&amount=10&resp=html"> Confirm Load Value </a> </p></li>');
上面的几行效果很好,它是动态创建html元素,并创建了一个带有heref链接的html元素,按下该链接时会进行API调用
并且我得到的响应是html或xml格式,但问题是我无法抓取响应并以自定义格式显示该响应.因此,我尝试了另一种方式,即对api调用进行ajax调用以获取响应并进一步使用,但是它无法正常工作,没有响应,我不知道我做错了什么还是有其他处理方法.您能帮我打一个正确的Ajax电话并获取结果吗?.
代码从这里开始
above lines works fine what it does is to make a html element dynamically and it creates a an html element with heref link which is when pressed makes an API call
and the response I get is in html or xml format but the problem is I cannot grab the response and show that in a customized format. so I tried another way which is ajax call for the api call to grab the response and use further but its not working no response I don''t know if I am doing some thing wrong or there is some other way of doing it. Can you help me make a proper ajax call and grab the results?.
Code starts here
(文档).ready(函数(){
(document).ready(function() {
(' #makecall').click(函数(){
('#makecall').click( function() {
这篇关于通过ajax向第三方API发送https请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!