在Sails.js中未触发Ajax表单操作 [英] Ajax form action not triggered in Sails.js
问题描述
我在Sails.js中创建了一个动作,以在数据库中创建一个条目(添加客户).然后,我在EJS中创建了一个表单.(我的代码基于注册路线/表单)
I created an action in Sails.js to create an entry in a database (add a customer). Then I created a form in EJS. (My code is based on the signup route / form)
我有我的 Customer.js
模型
我有我的 view-create-customer.js
我有我的 create-customer.page.js
我有我的控制器操作" create-customer.js
I have my controller "action" create-customer.js
cloud.setup.js具有"createCustomer":{"verb":"POST","url":"/api/v1/entrance/create-customer","args":["customerName",状态"]}
cloud.setup.js has "createCustomer":{"verb":"POST","url":"/api/v1/entrance/create-customer","args":["customerName","status"]}
在routes.js中,我有:
In routes.js I have :
'POST /api/v1/entrance/create-customer': { action: 'entrance/create-customer' },
我的EJS表单中的ajax表单:
The ajax-form in my EJS Form I have :
<ajax-form action="createCustomer" :syncing.sync="syncing" :cloud-error.sync="cloudError" @submitted="submittedForm()" :handle-parsing="handleParsingForm">
该表单显示得很好,但是当我单击提交"时,什么也没有发生.没有错误,没有触发ajax.
The form displays just fine, but nothing happens when I click submit. No error, no ajax triggered.
我尝试使用POSTMAN POST到API网址,并且按预期方式创建了我的客户.
I tried to POST to the API url with POSTMAN and my customer was created as expected.
有什么主意吗?
推荐答案
在修改端点后,您是否尝试过运行 sails运行rebuild-cloud-sdk
?邮递员应该工作,因为它没有使用ajax表单组件操作中使用的SailsJs云".
have you tried running sails run rebuild-cloud-sdk
after modifying your endpoint? Postman should work as it doesn't use the SailsJs 'Cloud' used in the action of the ajax-form component.
还可以分享POSTMAN的回复吗?
Also, can you share the response from POSTMAN ?
这篇关于在Sails.js中未触发Ajax表单操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!