pooriaasefi
دوشنبه 24 آبان 1395, 18:46 عصر
سلام و عرض خسته نباشید
بنده دارم از یه سورس ارسال نظر با تکنولوژی ajax استفاده میکنم
برای ایینکه بخوام اطلاعات هر صفحه داخل دیتابیس مورد نظرش قرار بگیره هر کاری میکنم نمیدونم چجوری از اون تابعی که در php استفاده کردم در فایل جاوا هم استفاده کنم
با کد پایین نظراتِ داخل تیبل مربوط به فرم مورد نظر ، فراخوانی میشه تو صفحه
$form_id = (int)trim($_GET['form_id']);
if (empty($form_id) OR 10000>($form_id) OR ($form_id)>99999) {
die("درخواست صحیح نیست");
} else {
$comments = array();
$result = mysql_query("SELECT * FROM `comments_{$form_id}` ORDER BY id ASC");
while($row = mysql_fetch_assoc($result))
{
$comments[] = new Comment($row);
}
}
تو کد پایین بجای {$form_id} در جاوا چه کدی باید قرار بگیره که بتونه مثله پی اچ پی عمل کنه
برای ثبت شدن نظرات در دیتابیس حتما باید {$form_id} عمل کنه وگرنه ثبت نمیشه نظری
$(document).ready(function(){
/* The following code is executed once the DOM is loaded */
/* This flag will prevent multiple comment submits: */
var working = false;
/* Listening for the submit event of the form: */
$('#addCommentForm').submit(function(e){
e.preventDefault();
if(working) return false;
working = true;
$('#submit').val('Working..');
$('span.error').remove();
/* Sending the form fileds to submit.php: */
$.post('submit.php?form_id={$form_id}',$(this).ser ialize(),function(msg){
working = false;
$('#submit').val('Submit');
if(msg.status){
/*
/ If the insert was successful, add the comment
/ below the last one on the page with a slideDown effect
/*/
$(msg.html).hide().insertBefore('#addCommentContai ner').slideDown();
$('#body').val('');
}
else {
/*
/ If there were errors, loop through the
/ msg.errors object and display them on the page
/*/
$.each(msg.errors,function(k,v){
$('label[for='+k+']').append('<span class="error">'+v+'</span>');
});
}
},'json');
});
});
شرمنده نمیدونم اصلا میشه همچین کاری کرد یا خیر:ناراحت:
بنده دارم از یه سورس ارسال نظر با تکنولوژی ajax استفاده میکنم
برای ایینکه بخوام اطلاعات هر صفحه داخل دیتابیس مورد نظرش قرار بگیره هر کاری میکنم نمیدونم چجوری از اون تابعی که در php استفاده کردم در فایل جاوا هم استفاده کنم
با کد پایین نظراتِ داخل تیبل مربوط به فرم مورد نظر ، فراخوانی میشه تو صفحه
$form_id = (int)trim($_GET['form_id']);
if (empty($form_id) OR 10000>($form_id) OR ($form_id)>99999) {
die("درخواست صحیح نیست");
} else {
$comments = array();
$result = mysql_query("SELECT * FROM `comments_{$form_id}` ORDER BY id ASC");
while($row = mysql_fetch_assoc($result))
{
$comments[] = new Comment($row);
}
}
تو کد پایین بجای {$form_id} در جاوا چه کدی باید قرار بگیره که بتونه مثله پی اچ پی عمل کنه
برای ثبت شدن نظرات در دیتابیس حتما باید {$form_id} عمل کنه وگرنه ثبت نمیشه نظری
$(document).ready(function(){
/* The following code is executed once the DOM is loaded */
/* This flag will prevent multiple comment submits: */
var working = false;
/* Listening for the submit event of the form: */
$('#addCommentForm').submit(function(e){
e.preventDefault();
if(working) return false;
working = true;
$('#submit').val('Working..');
$('span.error').remove();
/* Sending the form fileds to submit.php: */
$.post('submit.php?form_id={$form_id}',$(this).ser ialize(),function(msg){
working = false;
$('#submit').val('Submit');
if(msg.status){
/*
/ If the insert was successful, add the comment
/ below the last one on the page with a slideDown effect
/*/
$(msg.html).hide().insertBefore('#addCommentContai ner').slideDown();
$('#body').val('');
}
else {
/*
/ If there were errors, loop through the
/ msg.errors object and display them on the page
/*/
$.each(msg.errors,function(k,v){
$('label[for='+k+']').append('<span class="error">'+v+'</span>');
});
}
},'json');
});
});
شرمنده نمیدونم اصلا میشه همچین کاری کرد یا خیر:ناراحت: