How to render html that nodejs res.send to me?

framework7 form ajax data to my nodejs server, after that, nodejs server return me some html, but how to render those html with framework7? i use framework7 core.

Provide the full code on how and where you receive the data and where do you want to insert it

frontend runnning on http://localhost:8080

  <div class="page" data-name="about">
    <div class="navbar">
      <div class="navbar-bg"></div>
      <div class="navbar-inner sliding">
        <div class="left">
          <a href="#" class="link back">
            <i class="icon icon-back"></i>
            <span class="if-not-md">Back</span>
        <div class="title">关于</div>
    <div class="page-content">
      <div class="block-title">生活是一场梦</div>
      <div class="block block-strong">
        <div class="display-flex justify-content-center">
          <!-- <button class="button button-raised button-fill auto-width">赞助我</button> -->
          <form action="http://localhost:3000/alipay" method="POST" class="fit-content-width form-ajax-submit list" id="donate-form">
                <div class="item-content item-input">
                  <div class="item-inner">
                    <div class="item-title item-label">金额</div>
                    <div class="item-input-wrap">
                      <input required validate type="number" pattern="^\d+(\.\d{1,2})?$" min="0.01" step="0.01" name="totalAmount" placeholder="我会珍惜你的鼓励" >
                <div class="item-content item-input">
                  <div class="item-inner">
                    <div class="item-input-wrap">
                      <input type="submit" class="button button-raised button-fill" value="捐赠">

  export default {};

backend running on http://localhost:3000

var express = require('express');
var AlipaySdk = require('alipay-sdk').default;
var AlipayForm = require('alipay-sdk/lib/form').default;
var fs = require('fs');
var path = require('path');


var appId, alipayPublicKey, gateway;

if (process.env.NODE_ENV === "production") {
    appId = process.env.ALIPAY_APPID;
    alipayPublicKey = fs.readFileSync(path.join(__dirname, '../alipay_public.pem'), 'ascii');
    gateway = process.env.ALIPAY_GATEWAY;
} else {
    appId = process.env.SANDBOX_ALIPAY_APPID;
    alipayPublicKey = fs.readFileSync(path.join(__dirname, '../sandbox_alipay_public.pem'), 'ascii');
    gateway = process.env.SANDBOX_ALIPAY_GATEWAY;

var formData = new AlipayForm();

// formData.setMethod('get');
formData.addField('returnUrl', 'http://localhost:8080');

var alipaySdk = new AlipaySdk({
    privateKey: fs.readFileSync(path.join(__dirname, '../private.pem'), 'ascii'),

var router = express.Router();'/', function (req, res, next) {
    var outTradeNo = (new Date()).toISOString();
    var totalAmount = req.body.totalAmount;
    console.log(`totalAmount ${totalAmount}`);
    console.log(typeof totalAmount);
    // console.log(req);

    if ((/^\d+(\.\d{1,2})?$/g).test(totalAmount)) {
        formData.addField('bizContent', {
            productCode: 'FAST_INSTANT_TRADE_PAY',
            subject: '捐赠',
            body: '无偿捐赠'

            { formData },
        ).then(result => {
            //result is some html...
            return res.send(result);
        }).catch((err) => {
            // ...

    } else {
        return res.end();


module.exports = router;

returned html is like below:

	method="post" name="alipaySDKSubmit1571405321068" id="alipaySDKSubmit1571405321068">
	<input type="hidden" name="alipay_sdk" value="alipay-sdk-nodejs-3.0.8" /><input type="hidden" name="biz_content" value="{&quot;out_trade_no&quot;:&quot;2019-10-18T13:28:41.053Z&quot;,&quot;total_amount&quot;:&quot;0.02&quot;,&quot;product_code&quot;:&quot;FAST_INSTANT_TRADE_PAY&quot;,&quot;subject&quot;:&quot;捐赠&quot;,&quot;body&quot;:&quot;无偿捐赠&quot;}" />

i don’t know how to render my server returned html and insert it where.please help me.

@shastox @wouterb
can you answer my problem?

Do you know what is XHR/Ajax/Fetch? In F7 you need to submit forms dynamically, e.g. send required data to required endpoint with Ajax.

i have done it but i dont’t know how to render returned html directly in f7-core

Where and how in your code you are doing ajax request?

please look at top frontend snippet. :point_up_2:

Add this listener for getting the data on ajax request success:

$$(’#donate-form’).on(‘formajax:success’, function (e) {
var xhr = e.detail.xhr; // actual XHR object

var data =; // Ajax response from action file
// do something with response data

Read the docs here:

i know this. but my response data is form html snippets, how can i render returned form in f7-core ?

В чем именно ваша проблема? Вы не знаете как вставит HTML-код с сервера в текущую страницу? Куча сообщений, но вы так не смогли сформулировать вопрос.

I don’t know how to insert the HTML code from the server into the current page? please teach me.