weixin_42269052
程序新新新人
2020-04-06 12:15
采纳率: 83.3%
浏览 260

微信小程序通过 C#的接口传值,没有反应,也不报错

这个我本地写的一个接口

这个是我的调用代码

我的想法是通过js直接调用C#的接口,然后传值,把接口当一个中转站,把值传过去。

我现在修改了写法,这样提示错误了,是什么原因呢?

 wx.request({
        url: 'http://localhost:200/WebService.asmx?op=InpUser',
        method: 'POST',
        header: {
          'content-type': 'application/x-www-form-urlencoded'
        },
        data: {
          Name: this.data.MyName,
          Phone: this.data.MyPhone,
          LFY: this.data.MyLFY,
          Email: this.data.MyEmail
        },
        success: function (res) {
          if (res.data.err == 0) {
            wx.showToast({
              title: '保存成功',
              success: res => {
                setTimeout(function () {
                  wx.switchTab({
                    url: '/pages/TextInput/TextInput',
                  })
                }, 2000);
              }
            })
          } else {
            that.setData({
              msg: res.data.errtxt
            })
          }
        }

错误提示

POST http://localhost:200/WebService.asmx?op=InpUser 500 (Internal Server Error)
v @ VM1687 asdebug.js:1
createRequestTask @ VM1687 asdebug.js:1
n @ VM1687 asdebug.js:1
invoke @ VM1689 WAService.js:2
l @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
y @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
rc @ VM1689 WAService.js:2
a @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
n @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
p.<computed> @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
loginBtnClick @ test.js? [sm]:36
r.safeCallback @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
c @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
r @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
n @ VM1687 asdebug.js:1
(anonymous) @ VM1687 asdebug.js:1
(anonymous) @ VM1687 asdebug.js:1
_ws.onmessage @ VM1687 asdebug.js:1
VM1683:1 thirdScriptError
that is not defined;at api request success callback function
ReferenceError: that is not defined
    at success (http://127.0.0.1:25869/appservice/pages/test/test.js:62:13)
    at Object.o.<computed> (http://127.0.0.1:25869/appservice/__dev__/WAService.js:2:1431866)
    at http://127.0.0.1:25869/appservice/__dev__/WAService.js:2:589634
    at Module.c (http://127.0.0.1:25869/appservice/__dev__/WAService.js:2:1591990)
    at Function.<anonymous> (http://127.0.0.1:25869/appservice/__dev__/WAService.js:2:589609)
    at http://127.0.0.1:25869/appservice/__dev__/WAService.js:2:127365
    at E (http://127.0.0.1:25869/appservice/__dev__/WAService.js:2:541004)
    at i.<anonymous> (http://127.0.0.1:25869/appservice/__dev__/WAService.js:2:920298)
    at i.emit (http://127.0.0.1:25869/appservice/__dev__/WAService.js:2:599114)
    at ic (http://127.0.0.1:25869/appservice/__dev__/WAService.js:2:921160)
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • caozhy
    已采纳

    你的webservice是基于soap的,而你提交的数据是json,这就好比一个美国人用英文和一个中国人说话,当然没用。

    点赞 评论

相关推荐