I'm not able to take the contents of a div to PHP with Jquery.
What would be the problem for me?
My code
Html
<form role="form" name="form1" id="form1" method="post" action="" enctype="multipart/form-data">
<input type="hidden" id="id_oquefizemos" name="id_oquefizemos" class="form-control" value="">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<div class="form-group">
<label class="col-md-12">Título</label>
<div class="col-md-12">
<input type="text" name="titulo" value="" placeholder="Título Categoria" class="form-control form-control-line">
</div>
</div>
<div class="form-group">
<label for="example-email" class="col-md-12">Imagem</label>
<div class="col-md-12">
<input type="file" class="form-control form-control-line" name="foto_oquefizemos" id="foto_oquefizemos">
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<div class="wmd-panel">
<div id="wmd-button-bar-0" class="wmd-button-bar">
<div id="wmd-button-row-0" class="btn-toolbar">
<div class="btn-group wmd-button-group1" id="wmd-button-group1-0">
<button class="btn btn-default" id="wmd-bold-button-0" title="" data-original-title="Bold - Ctrl+B">
<i class="fa fa-bold"></i>
</button>
<button class="btn btn-default" id="wmd-italic-button-0" title="" data-original-title="Italic - Ctrl+I">
<i class="fa fa-italic"></i>
</button>
</div>
<div class="btn-group wmd-button-group2" id="wmd-button-group2-0">
<button class="btn btn-default" id="wmd-link-button-0" title="" data-original-title="Link - Ctrl+L">
<i class="fa fa-link"></i>
</button>
<button class="btn btn-default" id="wmd-quote-button-0" title="" data-original-title="Blockquote - Ctrl+Q">
<i class="fa fa-quote-left"></i>
</button>
<button class="btn btn-default" id="wmd-code-button-0" title="" data-original-title="Code Sample - Ctrl+K">
<i class="fa fa-code"></i>
</button>
<button class="btn btn-default" id="wmd-image-button-0" title="" data-original-title="Image - Ctrl+G">
<i class="fa fa-picture-o"></i>
</button>
</div>
<div class="btn-group wmd-button-group3" id="wmd-button-group3-0">
<button class="btn btn-default" id="wmd-olist-button-0" title="" data-original-title="Numbered List - Ctrl+O">
<i class="fa fa-list-ol"></i>
</button>
<button class="btn btn-default" id="wmd-ulist-button-0" title="" data-original-title="Bulleted List - Ctrl+U">
<i class="fa fa-list-ul"></i>
</button>
<button class="btn btn-default" id="wmd-heading-button-0" title="" data-original-title="Heading - Ctrl+H">
<i class="fa fa-header"></i>
</button>
<button class="btn btn-default" id="wmd-hr-button-0" title="" data-original-title="Horizontal Rule - Ctrl+R">
<i class="fa fa-ellipsis-h"></i>
</button>
</div>
<div class="btn-group wmd-button-group4" id="wmd-button-group4-0">
<button class="btn btn-default" id="wmd-undo-button-0" title="" data-original-title="Undo - Ctrl+Z"
disabled="">
<i class="fa fa-undo"></i>
</button>
<button class="btn btn-default" id="wmd-redo-button-0" title="" data-original-title="Redo - Ctrl+Y"
disabled="">
<i class="fa fa-rotate-right"></i>
</button>
</div>
<div class="btn-group wmd-button-group5 pull-right" id="wmd-button-group5-0">
<button class="btn" id="wmd-help-button-0" title="" data-original-title="Markdown Editing Help">
<i class="fa fa-question"></i>
</button>
</div>
</div>
</div>
<textarea name="texto" id="wmd-input-0" class="form-control editor wmd-input" rows="10"></textarea>
<div id="wmd-preview-0" class="wmd-preview"></div>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<hr>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<input name="cadastrar" type="submit" id="cadastrar" value="Cadastrar Categoria " class="btn btn-default">
</div>
</div>
</div>
</div>
</div>
</form>
Jquery
<script type="text/javascript">
(function () {
// $("textarea#pagedownMe").pagedownBootstrap();
$("textarea#pagedownMeDangerously").pagedownBootstrap({
'sanitize': false,
'help': function () { alert("Do you need help?"); },
'hooks': [
{
'event': 'preConversion',
'callback': function (text) {
return text.replace(/\b(a\w*)/gi, "$1");
}
},
{
'event': 'plainLinkText',
'callback': function (url) {
return "This is a link to " + url.replace(/^https?:\/\//, "");
}
}
]
});
})();
$(function(){
$("#cadastrar").click(function(){
var conteudo = $("#wmd-preview-0").text(); //<----
$.post('dicas_categoria.php', {
texto_descricao: conteudo
}, function(response){
// Aqui ficará a lógica que será executada quando sua
// requisição for enviada e a página PHP te der uma resposta
});
});
})
</script>
Php
<? echo $_POST['nome']; ?>
I tried this way but did not give
$("#form1").submit(function(){ var nome = $('.wmd-preview').html(); });