Answer the question
In order to leave comments, you need to log in
Form not passing select?
I'm trying to submit the form via ajax but the data selected in the select is not passed to
Select
<select name="post_category" id="post_category" class="form-control">
<option value="0">
Изменить категорию
</option>
<?php foreach ($wo['feed_categories'] as $category_id => $category_name):?>
<option value="<?php echo $category_id?>" <?php if($category_id == $wo['story']['category']) echo "selected='selected'" ;?> ><?php echo $category_name;?></option>
<?php endforeach;?>
</select>
function Wo_EditPost(post_id) {
var post = $('#post-' + post_id);
var edit_box = $('#post-' + post_id).find('#edit-post');
var edit_textarea = post.find('.edit-textarea-' + post_id + ' textarea');
var text = edit_textarea.val();
$("#form-control").val()
var post_text = post.find('.post-description p');
Wo_progressIconLoader(post.find('#edit-post-button'));
$('#post-' + post_id).find('#edit-post .ball-pulse').fadeIn(100);
$.post(Wo_Ajax_Requests_File() + '?f=posts&s=edit_post', {
post_id: post_id,
text: text,
post_category: post_category
}, function (data) {
if(data.status == 200) {
post_text.html(data.html);
edit_box.modal('hide');
}
$('#post-' + post_id).find('#edit-post .ball-pulse').fadeOut(100);
if (data.can_send == 1) {
Wo_SendMessages();
}
});
}
if ($s == 'edit_post') {
if (Wo_CheckSession($hash_id) === true) {
if (!in_array($_POST['post_category'], array_keys($wo['page_categories']))) {
$error = $error_icon . $wo['lang']['error_found'];
}
}
if (!empty($_POST['post_id']) && !empty($_POST['text'])&& !empty($_POST['post_category'])) {
$updatePost = Wo_UpdatePost(array(
'post_id' => $_POST['post_id'],
'text' => $_POST['text'],
'post_category' => $_POST['post_category']
));
if (!empty($updatePost)) {
$data = array(
'status' => 200,
'html' => $updatePost
);
if (Wo_CanSenEmails()) {
$data['can_send'] = 1;
}
}
}
header("Content-type: application/json");
echo json_encode($data);
exit();
}
Answer the question
In order to leave comments, you need to log in
not getting data from list
var post_category=document.getElementById("post_category").value
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question