0

这是我的表格

HTML

<div id="contactus">
     <form action="carrer_.php" method="POST" ENCTYPE="multipart/form-data" class="contactUs" id="send_cv" target="carrer_iframe">
        <label> Name
          <input type="text" name="name"  />
        </label>

        <label> Email
          <input type="text"  name="email" />
        </label>

        <label> Mobile
          <input type="text" class="mobile" name="mobile" />
        </label>

        <label> Cv
           <input type="file" id="cv" name="file" />
        </label>

        <label> Other Info
          <textarea name="message" cols="1" rows="1"></textarea>
        </label>
        <input type="submit" value="send" />
      </form>
      <div id="iframe_result"></div>
      <iframe name="carrer_iframe" id="carrer_iframe" src="carrer_.php" style="width;0;height:0;display:none;" ></iframe>
    </div>

JS

 $('#send_cv').submit( function(){
        $("#carrer_iframe").contents().html("") ;
        $("#iframe_result").load(function(){
                alert( 1 ) ;
                response = $("#carrer_iframe").contents().find("body:last").text();
                alert( response ) ;
                $("#iframe_result").html(response).show();
            });
  } ) ;

提交表格后(什么都没发生???)

我如何从隐藏的 iframe 中获取结果并提醒它 && 或者我的错误是什么

最好的祝福

4

1 回答 1

0

似乎没有什么可以阻止表单正常提交。尝试从提交函数传递事件并调用.preventDefault

$('#send_cv').submit( function(event){
        // Preventing the default form submission action
        event.preventDefault();
        $("#carrer_iframe").contents().html("") ;
        $("#iframe_result").load(function(){
                alert( 1 ) ;
                response = $("#carrer_iframe").contents().find("body:last").text();
                alert( response ) ;
                $("#iframe_result").html(response).show();
            });
  } ) ;

编辑:

据我所知 .show() 只影响显示属性。因此将 wdith/height 设置为 0 将意味着 iframe 永远不会显示。

于 2012-10-07T17:58:34.520 回答