
Attachment in Ajax
Hi,
I have a form where a file has to be uploaded. I am using an Ajax post script. The input fields are processed correctly, but the attachment isn't. Any clous?
The script:
<script>
$(document).ready(function(){
$('#nieuwsberichten').submit(function(){
$('#response').html("<center><img src={% file_asset_url 'spin.gif' %}></center>");
$.ajax({
type: 'POST',
url: '/hoofdpagina/post/bijlagen',
data: $(this).serialize()
})
.done(function(){
// e.preventDefault(); //To prevent the default anchor tag behaviour
var url = '/hoofdpagina/start';
$("#main").load(url, function() {
$("#loading").hide()})
})
.fail(function() {
alert( "Posting failed." );
});
// to prevent refreshing the whole page page
return false;
});
});
</script>
Corné
Hi,
I have a form where a file has to be uploaded. I am using an Ajax post script. The input fields are processed correctly, but the attachment isn't. Any clous?
The script:
<script>
$(document).ready(function(){
$('#nieuwsberichten').submit(function(){
$('#response').html("<center><img src={% file_asset_url 'spin.gif' %}></center>");
$.ajax({
type: 'POST',
url: '/hoofdpagina/post/bijlagen',
data: $(this).serialize()
})
.done(function(){
// e.preventDefault(); //To prevent the default anchor tag behaviour
var url = '/hoofdpagina/start';
$("#main").load(url, function() {
$("#loading").hide()})
})
.fail(function() {
alert( "Posting failed." );
});
// to prevent refreshing the whole page page
return false;
});
});
</script>
Corné
Login to reply