Use iframe to submit form without refreshing the page

Use iframe to submit form without refreshing the page
So we introduce an embedding framework to solve this problem. The specific principle is: when the form submits data, the submission target is not set to the current page, but to an embedded frame in the current page.
First you should insert an inline frame below the body:

Copy code
The code is as follows:
<iframe style="width:0; height:0; margin-top:-10px;" name="submitFrame" src="about:blank"></iframe>

You should then set the form's target to be this embedded frame, like this:

Copy code
The code is as follows:
<form name="testform" method="post" action="apply.cgi" target="submitFrame"> <input type="submit" value="Submit"> </form>

This way we get what we need.

<<:  Example code for implementing a three-column layout with CSS, where the middle column is adaptive and changes width with text size

>>:  Several commonly used single-page application website sharing

Recommend

js regular expression lookahead and lookbehind and non-capturing grouping

Table of contents Combining lookahead and lookbeh...

Create a virtual environment using venv in python3 in Ubuntu

1. Virtual environment follows the project, creat...

Complete steps for vue dynamic binding icons

0 Differences between icons and images Icons are ...

JS ES new features: Introduction to extension operators

1. Spread Operator The spread operator is three d...

Example of using CSS to achieve semi-transparent background and opaque text

This article introduces an example of how to use ...

How to change $ to # in Linux

In this system, the # sign represents the root us...

How to query duplicate data in mysql table

INSERT INTO hk_test(username, passwd) VALUES (...

Example analysis of interval calculation of mysql date and time

This article uses an example to describe the inte...

Analyzing ab performance test results under Apache

I have always used Loadrunner to do performance t...

HTML table tag tutorial (31): cell width and height attributes WIDTH, HEIGHT

By default, the width and height of the cell are ...

Practice of using SuperMap in Vue

Table of contents Preface Related Materials Vue p...

HTML+CSS merge table border sample code

When we add borders to table and td tags, double ...

Detailed explanation of basic data types in mysql8.0.19

mysql basic data types Overview of common MySQL d...

How to use Docker container to access host network

Recently, a system was deployed, using nginx as a...