我有一个简单的html页面,其中包含一个打开模态窗口的链接。 在模态窗口中是一个表单。 如何提交表单并在同一模式窗口中显示“表单操作(test.asp)”页面。 test.asp页面是数据库条目/感谢您填写表单页面。
import numpy as np
import scipy
from scipy.optimize import leastsq, fmin_tnc
from numpy import sin, cos, arctan, pi, sqrt
from numpy.random import standard_normal
import sys
import scipy.stats
import os
import time
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
n=(input('how many residues?'))
pathInput='/Users/luca/Desktop/GLOBAL FITTING/global fitting/input'
pathOutput='/Users/luca/Desktop/GLOBAL FITTING/global fitting/output'
l=os.listdir(pathInput)
finalInput=pathOutput+"/mergedInput.txt"
out=open(finalInput,'w')
out1=open(pathOutput+"/inputFilenames.txt",'w')
r1 = [2.25 ,3, 2, 4]
r2 = [ 24.62, 30, 20, 25]
EF = 1
data = np.genfromtxt(datafile_name)
x = data[:,0]
y = data[:,1]
err = data[:,2]*EF
z = data[:,3]
kex = 1311
pop = 0.025
dw = [-300,500,700,650]
i=0
while i < len(r1):
p0 = [r1[i], r2[i], kex, pop, dw[i]]
plsq = leastsq(residuals, p0, args=( x, y, z, err),
full_output = True,
xtol = 1e-15,
ftol = 1e-15,
factor = 1 )
pres, cov_x, infodict, mesg, ier = plsq
print pres[0], pres[1], pres[2], pres[3], pres[4]
i=i+1
答案 0 :(得分:2)
尝试使用javascript函数event.preventDefault()
来阻止模式关闭:
function overlay() {
el = document.getElementById("overlay");
el.style.visibility =
(el.style.visibility == "visible" ? "hidden" : "visible");
document.getElementById("submit").addEventListener("click",
function(event){
event.preventDefault();
}
);
}
&#13;
#overlay {
visibility: hidden; position: absolute; left: 0px; top: 0px;
width: 100%; height: 100%; text-align:center; z-index: 1000;
}
#overlay div {
width: 300px; margin: 100px auto; background-color: #fff;
border: 1px solid #000; padding: 15px; text-align: center;
}
&#13;
<!DOCTYPE html>
<html>
<body>
<a href='#' onclick='overlay()'>Click here to show the overlay</a>
<div id="overlay">
<div>
<p>Please complete the form below.</p>
<form action="test.asp" method="post" id="contact-form">
<input type="text" name="field1"><br>
<input type="text" name="field2"><br>
<input type="submit" id="submit" value="Go">
</form><br>
Click here to [<a href='#' onclick='overlay()'>close</a>]<br>
</div>
</div>
</body>
</html>
&#13;
之后,在同一窗口中使用Jquery为下一页加载发出一个AJAX请求:
$.ajax({
url: '/path/to/file',
type: 'default GET (Other values: POST)',
dataType: 'default: Intelligent Guess (Other values: xml, json, script, html)',
data: {param1: 'value1'},
}).done(function() {
console.log("success");
}).fail(function() {
console.log("error");
}).always(function() {
console.log("complete");
});