0
我有一個頁面,允許用戶從數據庫編輯記錄。簡單。jQuery不會在頁面上工作
HTML源代碼看起來是這樣的:
<form id="prize_modify_form" enctype="multipart/form-data" action="" method="POST" accept-charset="utf-8">
<p><label for="header">Header</label><input type="text" name="header" value="More Tvs!" id="header"></p>
<p><label for="description">Description</label><input type="text" name="description" value="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." id="description"></p>
<p><label for="short_description">Short Description</label><input type="text" name="short_description" value="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure d" id="short_description"></p>
<p><label for="expiration_date">Expiration Date</label><input type="text" name="expiration_date" value="0000-00-00" id="expiration_date"></p>
<p><label for="image">Image</label>
<a href="#" id="change_image_link">Change Image</a>
<input type="hidden" name="photo" value="png8.png" id="photo">
</p>
<p><input type="submit" value="Save"></p>
</form>
<link rel="stylesheet" href="../../css/jquery-ui-1.7.2.custom.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/jquery.validate.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/additional-methods.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
alert('inside');
// Set up the validations
$('#prize_modify_form').validate({
rules: {
header: {
required: true,
minlength: 2
},
description: {
required: true,
minlength: 2
},
short_description: {
required: true,
minlength: 2,
maxlengh: 250
}
image: {
required: true,
accept: "jpg|jpeg|gif|png"
},
expiration_date: {
required: true,
dateITA: true
}
}
});
// Add the date picker to expiration date
$('#expiration_date').datepicker();
// Redirect the page and create a popup for the change image link
$('#change_image_link').click(function(){
$id = $('#id').attr('value');
$prize_id = $("#prize_id").attr('value');
window.open("image.upload.php?id=" + $id,"Upload Image",
"menubar=no,width=430,height=100,toolbar=no");
});
});
</script>
裏面的我的jQuery代碼,從來都沒有被運行。 最大的問題是,這個網頁幾乎是另一個頁面的複製粘貼...完美的作品。 我不太清楚問題出在哪裏。
檢查錯誤Firefox的錯誤控制檯,Firebug的「網絡」選項卡,以瞭解是否所有文件正確加載。 – 2010-01-29 17:50:36
奇怪的是,Firefox或Chrome都沒有顯示錯誤。 – 2010-01-29 18:00:03