0

I have a first page of a form, and then I use jQuery to load the second part of the form. However, after I click submit on the form, nothing happens, the page is just stuck here. Any ideas?

jQuery:

       $.ajax({
            type: "POST",
            url: "join_submit.php",                     
            data: data, 
            success: function () {
                $("#regform").load("submitTranscript.php");
            }
       });          

submitTranscript.php:

 <div id="regform>
 <form id="uploadTranscript" action="uploadPDF.php" enctype="multipart/form-data" method="post">
<div class="separation">
    <h3>Upload Transcripts</h3>
    <div class = "row">
        <div class="large-6 offset-2 columns">
        <label for = "studid">Enter your student ID:</lable>
            <input type="text" name="studid" id="studid"
    </div>
    <p>Please label your transcript with your user id (i.e. 123456.pdf).</p>
    <div class="row">
        <div class="large-6  offset-2 columns">
            <input type="file" name="transcript" id="transcript">
        </div>
    </div>
    <div class="buttonRow">
        <div class="button" id="submit">Submit</div>
    </div>
   </div>
  </form>
 </div>

uploadPDF.php:

<?php
require_once("included.php"); //server info
$allowedExtensions = array("pdf");
$max_filesize = 20000;
$upload_path = "docs/transcripts/";
$filename = $_FILES["transcript"]["name"];  
$filesize = $_FILES["transcript"]["size"];
$extension = $_FILES["transcript"]["type"];
 if ($_FILES["transcript"]["error"] > 0) {
        echo "Error: " . $_FILES["transcript"]["error"] . "<br />";
    }
else if((in_array($extension, $allowedExtensions)) && ($filesize < $max_filesize)) {
    move_uploaded_file($_FILES["transcript"]["tmp_name"], $upload_path . $filename);
}
else if($filesize > $max_filesize){
    $fileSizeFail = true;
}
else {                      
    $fileTypeFail = true;
}   
 ?>
4

2 回答 2

3

如果我查看 submitTranscript.php,您为提交表单编写了以下代码:

<div class="buttonRow">
    <div class="button" id="submit">Submit</div>
</div>

但是,您还没有插入任何提交按钮来提交表单。div 元素不能发布或提交任何表单。因此,我建议放置一个输入类型提交按钮,然后尝试通过该按钮提交您的表单。

所以代码将是:

<div class="buttonRow">
    <div class="button" id="submit">
        <input type="submit" name="form_submit" value="Submit" />
    </div>
</div>
于 2013-11-09T08:33:44.377 回答
0

您没有提供有关 join_submit.php 文件的任何信息。您必须检查 Firefox 浏览器中存在的 firebug 控制台,您的 join_submit.php 文件的返回值是什么。无论它是否会成功。然后只有您可以跟踪为什么它没有加载第二个表单。在 chrome 浏览器中,您可以通过单击 F12 然后单击 Network 来跟踪 ajax 请求。

希望能帮助到你

于 2013-11-09T08:36:34.127 回答