2011-09-01 4 views
0

이 코드가 성공시 양식을 지우지 않는 이유에 대해 혼란 스럽습니다. 나는 data-role = "collapsible"형식으로 양식을 사용하고 있습니다. 누군가가 성공 통화 후에 재설정 할 수 있도록 다른 것을 추가해야하는지 말해 줄 수 있습니까? 여기에 감사jquery mobile reset not clearing form

$(function() { 

$("#BRV_brtrv").submit(function() { 

    var send = $(this).serialize(); 

    $.ajax({ 
     type: "POST", 
     url: "boxrtrvajax.php", 
     cache: false, 
     data: send, 
     success: function (data) { 

     if (data == 'No data'){ 

     $('#brtv-result').addClass("result_msg").html('Please fill in all fields'); 
     } 
     else 
     { 
     $('#brtv-result').addClass("result_msg").html("You have successfully retrieved: "+data); 
     $("#BRV_brtrv").get(0).reset(); <-- this is the problem area --> 

     } 
    }, 
    error:function (xhr, ajaxOptions, thrownError){ 
     jAlert('There was an exception thrown somewhere'); 
     alert(xhr.status); 
     alert(thrownError); 
    } 
    }); 
    return false; 
    }); 
}); 

전체 형태와 JS : http://jsfiddle.net/Pg4SV/

+++

$(':input','#BRV_brtrv') 
.not(':button, :submit, :reset, :hidden') 
.val('') 
.removeAttr('checked') 
.removeAttr('selected'); 


$("input[type=range]").val(5).slider("refresh"); 
     $("input[type='checkbox']").attr("checked",false).checkboxradio("refresh"); 
     $("input[type='radio']").attr("checked",false).checkboxradio("refresh"); 
     $('#BRV-brtrv-department').selectmenu('refresh'); 

$(':input,:select', '#BRV_brtrv').removeAttr('checked').removeAttr('selected'); 

document.getElementById('BRV_brtrv').reset(); 

$('#BRV_brtrv').get(0).reset(); 

양식

<form method="post" id="BRV_brtrv" action=""> 

<div data-role="fieldcontain"> 
<label for="BRV_brtrvrb">Requested By *</label> 
<input type="text" name="BRV_brtrvrb" id="BRV_brtrvrb" value="<?php echo $_SESSION['name']; ?>" /> 
</div> 

<div data-role="fieldcontain"> 
<fieldset data-role="controlgroup" data-type="horizontal"> 
    <legend>Service Type *</legend> 
    <input type="radio" name="BRV-id-service-type" id="BRV-brtrv-standard-service" value="standard" /> 
    <label for="BRV-brtrv-standard-service">Standard</label> 
    <input type="radio" name="BRV-id-service-type" id="BRV-brtrv-rapid-service" value="rapid" /> 
    <label for="BRV-brtrv-rapid-service">Rapid</label> 
    </fieldset> 
</div> 

<div data-role="fieldcontain"> 
    <label for="BRV-brtrv-department">Department *</label> 
    <select name="BRV-brtrv-department" id="BRV-brtrv-department" class="select" data-inline="true" data-native-menu="false"> 
    <option>Choose Department</option> 
     <?php 
     while($row = mysql_fetch_array($BRVdept_result)) 
    { 
     $value=$row['name']; 
     $caption=$row['name']; 
     echo "<option value=\"", $value, "\">", $caption, "</option>"; 
     } 
    ?> 
    </select> 
</div> 

<div data-role="fieldcontain"> 
    <label for="BRV-brtrv-address">Address *</label> 
    <select name="BRV-brtrv-address" id="BRV-brtrv-address" class="select" data-inline="true" data-native-menu="false"> 
    <option>Choose Address</option> 
     <?php 
     while($row = mysql_fetch_array($BRVaddr_result)) 
     { 
     $value=$row['address1_com']. " ". $row['address2_com']. " ". $row['address3_com']. " ". $row['town_com']. " ". $row['postcode_com']; 
     $caption=$row['address1_com']. " ". $row['address2_com']. " ". $row['address3_com']. " ". $row['town_com']. " ". $row['postcode_com']; 
     echo "<option value=\"", $value, "\">", $caption, "</option>"; 
     } 
     ?> 
    </select> 
</div> 

<div data-role="fieldcontain"> 
    <label for="BRV-brtrv-slider">No of Boxes *</label> 
    <input type="range" name="BRV-brtrv-slider" id="BRV-brtrv-slider" data-track-theme="a" value="0" min="0" max="10" /> 
</div> 

<div id="BRVbrtrv_boxnumber" data-theme="b"></div> 

<div id="brtv-result"></div> 
<div id="BRV-brtrv-submitDiv" data-role="fieldcontain"> 
    <input name="BRV-brtrv-submit" id="BRV-brtrv-submit" type="submit" value="Retrieve Box" data-inline="true" /> 
</div> 
</form> 
+0

코드에 명백한 문제가 없습니다. 아마도 [JSFiddle] (http://jsfiddle.net/)을 제공해 주실 수 있습니까? – NobRuked

+0

@nobruked 바이올린 링크는 원래 게시물을 참조하십시오. 감사합니다 – bollo

답변

1

당신은 요소가있을 수 있습니다 시도

옵션 편집 +++ ID 또는 이름이 reset 인 양식 요소의 ID 또는 이름의 이름을 다른 것으로 변경해야합니다.

+0

윌리엄 원래 질문에 바이올린 링크를 참조하십시오 – bollo

+0

코드가 데스크톱에서 작동하는 것 같다 : http://jsfiddle.net/william/Pg4SV/4/. 내가 보내는 URL을 변경하고 제출 div 숨기기. 그냥 작동하지 않는 모바일일까요? –

+0

윌리엄 네. 감사합니다 – bollo