草庐IT

test_posts

全部标签

javascript - jQuery Ajax POST 不适用于 MailChimp

我使用以下代码将数据发送到MailChimp时事通讯列表(APIv3)。每次我从函数中删除type:POST时,它都会尝试通过GET发布数据并正确发送数据(MailChimpAPI仪表板中的正常响应)。在浏览器(FF)中对此进行测试时,我得到一个带有“真实”响应的.part文件。$(function(){$("a#test").click(function(e){e.preventDefault()data={"apikey":"667378947","id":"90298590285","email_address":"test@getmoxied.net","output":"js

javascript - 使用 fetch api 的 laravel 中的 Http Post 给出 TokenMismatchException

我正在尝试使用fetchapi制作一个http帖子。即使我正在发送token,我也会收到错误TokenMismatchExceptioninVerifyCsrfToken.php。如何使用fetchapi进行调用?(我也尝试过使用jQueryajax并且它完美地工作)这是获取api代码varURL=$("#form").attr("action");vartoken=$("input[name='_token']").val();vargroup_id=$(this).val();fetch(URL,{method:'post',mode:'no-cors',body:JSON.str

javascript - 使用 Async/Await 获取 API 'POST' 的正确方法

我正在从事一个需要我向API发出请求的项目。使用Async/Await发出POST请求的正确形式是什么?例如,这是我获取所有设备列表的请求。我将如何将此请求更改为POST以创建新设备?我知道我必须添加带有数据主体的header。getDevices=async()=>{constlocation=window.location.hostname;constresponse=awaitfetch(`http://${location}:9000/api/sensors/`);constdata=awaitresponse.json();if(response.status!==200)t

javascript - Angular Testing 异步管道不会触发可观察的

我想测试一个使用异步管道的组件。这是我的代码:@Component({selector:'test',template:`{{number|async}}`})classAsyncComponent{number=Observable.interval(1000).take(3)}fdescribe('AsyncCompnent',()=>{letcomponent:AsyncComponent;letfixture:ComponentFixture;beforeEach(async(()=>{TestBed.configureTestingModule({declarations:[

javascript - jquery如何获取post类型的ajax调用返回的状态消息?

javascript$('#send').on('click',function(){$.ajax({'url':$('#url').val(),'type':'post','complete':function(jqXHR,textStatus){varmsg="Status:"+jqXHR.status+"("+jqXHR.statusText+"-"+textStatus+")";msg+=jqXHR.getAllResponseHeaders().replace(/\n/g,"");$('#results').html(msg);}});});phpheader("HTTP/1

javascript - Rails + Jasmine-Ajax : what is the correct way to test code triggered by `ajax:success` (jquery-ujs)

我正在尝试测试某个内部库,该库在ajax:success事件上触发了一些JS行为。库创建一个如下所示的链接:在库的JS部分有事件绑定(bind)代码,这是我想通过它对DOM的影响进行黑盒测试的部分:$(document).on'ajax:success','.special-link',(e,data,status,xhr)->#CodethathassomeeffectontheDOMasafunctionoftheserverresponse该库在浏览器中按预期工作。但是,当我尝试通过调用$('.special-link').click()测试Jasmine中的库时,无法观察到对D

javascript - react 和 Jest : Cannot find module from test file

为目录中的Redux操作('App.js')设置Jest测试('App-test.js')app/__tests__:这是App.js的header:jest.unmock('../../modules/actions/App.js')importReactfrom'react'importReactDOMfrom'react-dom'importTestUtilsfrom'react-addons-test-utils'import*asAppfrom'../../modules/actions/App.js'在app/有一个模块config.js.这是在需要的地方导入的。问题是,当

javascript - JQuery Ajax POST 在没有发出请求的情况下抛出一个空错误

我有一个函数可以为任何anchor发出Ajax请求。请求方法可以是GET或POST。在这种情况下,我想在不使用表单的情况下进行POST,但是Ajax请求甚至在发送请求之前就抛出了错误。错误的值为“error”,所有错误/失败描述变量均为“”。functionloadPage(url,elem_id,method,data){ajaxLoading(elem_id);$.ajax({type:method,url:url,data:data,success:function(data){$("#"+elem_id).html(data);;},error:function(request

javascript - 如何测试 react-saga axios post

我正在学习如何测试并使用一些示例作为指导,我正在尝试模拟登录帖子。该示例使用fetch进行http调用,但我使用axios。这是我得到的错误Timeout-Asynccallbackwasnotinvokedwithintimeoutspecifiedbyjasmine.DEFAULT_TIMEOUT_INTERVAL此错误的所有答案都与获取有关,我如何使用axios执行此操作./传奇constencoder=credentials=>Object.keys(credentials).map(key=>`${encodeURIComponent(key)}=${encodeURICom

javascript - 在javascript中的HTTP POST请求中发送cookie

我正在尝试通过javascript向服务器(这是一个REST服务)发出一个POST请求,并且在我的请求中我想发送一个cookie。我的下面的代码不起作用,因为我无法接收cookie在服务器端。下面是我的客户端和服务器端代码。客户端:varclient=newXMLHttpRequest();varrequest_data=JSON.stringify(data);varendPoint="http://localhost:8080/pcap";varcookie="session=abc";client.open("POST",endPoint,false);//ThisPostwil