我正在使用bootstrap 3标签。所以我有多个哈希网址。每个散列网址都有一个表单:
example.org/documents
example.org/documents#home
example.org/documents#policies
example.org/documents#memos
我试图根据提交表单的网址将ajax调用中的数据返回到一个哈希网址。现在,数据被传递给所有散列的URL。如何在
中提交表单example.org/documents#home
显示传回的数据,而不是散列网址的其余部分。
每个表单中的所有数据都会在每个表单下传递回此范围:
<span class="responds"></span>
这是我的jquery:
$("form#contact").submit(function(e) {
e.preventDefault();
var formdata = new FormData(this);
$(".load-image").show();
$.ajax({
url: "php/upload.php",
type: "POST",
data: formdata,
mimeTypes: "multipart/form-data",
contentType: false,
cache: false,
processData: false,
})
.done(function(msg) {
$(".responds").after(msg);
$(".load-image").hide();
})
.fail(function(data) {
console.log(data);
$("#LoadingImage").hide();
})
});`
有没有办法在我的表单中传递散列网址,然后将其传递回.responds类?
以下是表格:
<div id="home" class="tab-pane fade in active">
<h3>Main</h3>
<ul class="list-group">
<?php $files = glob('docs/*.{pdf}', GLOB_BRACE); ?>
<?php foreach ($files as $file): ?>
<?php $filename = $file; ?>
<?php $vars = multiexplode(array('docs/', '.pdf'), $file); ?>
<br>
<li class="list-group-item">
<a target="_blank" href="<?php echo $file; ?>">
<span class="pull-right label label-default">
<?php echo date ("n/j/y", filemtime($filename)); ?>
</span>
<?php foreach ($vars as $var): ?>
<?php echo $var; ?>
<?php endforeach ?>
</a>
<?php if (true == in_array($idUser, $admin)): ?>
<form id="deleteFile" class="delete pull-left" action="php/deleteFile.php" method="post">
<input type="hidden" value="../<?php echo $file; ?>" name="file" id="file">
<button type="submit" class="btn btn-link btn-md" style="padding:0 5px 0 0; ">
<i class="fa fa-trash-o" aria-hidden="true"></i>
</button>
</form>
<?php endif ?>
<?php endforeach ?>
</li>
<span class="responds"></span>
</ul>
<?php if (true == in_array($idUser, $admin)): ?>
<form id="contact" class="contact" action="php/upload.php" method="post" enctype="multipart/form-data">
<div><b>Select a file to upload:</b></div>
<input type="hidden" value="../docs/" name="location" id="location">
<label class="btn btn-default btn-file">
<input type="file" name="fileToUpload" value="" id="file">
</label>
<br>
<br>
<label for="file_name">New File Name (optional)</label>
<div class="input-group">
<input type="text" class="form-control" name="new_name" placeholder="ESD 5 Handbook 11-2016" aria-describedby="file_name">
<span class="input-group-addon" id="file_name">.pdf</span>
</div>
<br>
<br>
<button type="submit" class="btn btn-default" name="submit" id="submit">
<i class="fa fa-upload" aria-hidden="true"></i> Upload File
<i class="fa fa-circle-o-notch fa-spin fa-1x fa-fw load-image" id="LoadingImage" style="display:none"></i>
</button>
</form>
<br>
<div class="alert" style="margin-bottom: 0px; padding: 5px;"></div>
<p class="bg-info">
Upload a new file. .pdf files only. Rename the file to according to how it is displayed. ie <code>Sample Document.pdf</code>
</p>
<?php endif ?>