Fix in posting
This commit is contained in:
parent
2d5be8a0ff
commit
e966aa492a
2 changed files with 53 additions and 72 deletions
|
|
@ -45,8 +45,6 @@
|
|||
/*-webkit-box-shadow: 0px 0px 160px 0px rgba(80,80,80,1);
|
||||
-moz-box-shadow: 0px 0px 160px 0px rgba(80,80,80,1);
|
||||
box-shadow: 0px 0px 160px 0px rgba(80,80,80,1);*/
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
box-shadow: 0px 0px 5px 5px rgba(0,0,0,0.33);
|
||||
-webkit-box-shadow: 0px 0px 5px 5px rgba(0,0,0,0.33);
|
||||
-moz-box-shadow: 0px 0px 5px 5px rgba(0,0,0,0.33);
|
||||
|
|
@ -94,5 +92,4 @@
|
|||
top: 24px;
|
||||
height: 32px;
|
||||
}
|
||||
>>>>>>> 811a1691680c070c92096fa1cdc3a061d8745033
|
||||
}
|
||||
|
|
|
|||
114
posting2.js
114
posting2.js
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
/* Add csrf token */
|
||||
|
||||
/* options: url: url to post, loading: dom id, success: func, pre_callback, separated_data:boolean, upload: {progressbar: '#progressbar', 'total_loader': '#total_loader', 'status': '#status'} */
|
||||
/* options: url: url to post, loading: dom id, success: func, pre_callback, separated_data:boolean */
|
||||
|
||||
$.fn.options={};
|
||||
|
||||
|
|
@ -25,44 +25,7 @@
|
|||
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
this.options=options;
|
||||
=======
|
||||
var xhr=false;
|
||||
|
||||
if(options.hasOwnProperty("upload")) {
|
||||
|
||||
xhr=function() {
|
||||
var myXhr = $.ajaxSettings.xhr();
|
||||
if(myXhr.upload){
|
||||
|
||||
var progressbar=options.upload.progressbar;
|
||||
var total_loader=options.upload.total_loader;
|
||||
var status=options.upload.status;
|
||||
|
||||
$(total_loader).html('');
|
||||
$(progressbar).attr('value', 0);
|
||||
$(status).html('');
|
||||
|
||||
myXhr.upload.addEventListener('progress',function (event) {
|
||||
|
||||
$(total_loader).html("Uploaded "+event.loaded+" bytes of "+event.total);
|
||||
var percent = (event.loaded / event.total) * 100;
|
||||
$(progressbar).attr('value', (Math.round(percent)));
|
||||
$(status).html(Math.round(percent)+"% uploaded... please wait");
|
||||
|
||||
}, false);
|
||||
|
||||
myXhr.addEventListener("load", function(event) {
|
||||
|
||||
$(status).html("Done!!");
|
||||
|
||||
}, false);
|
||||
}
|
||||
return myXhr;
|
||||
}
|
||||
}
|
||||
>>>>>>> 811a1691680c070c92096fa1cdc3a061d8745033
|
||||
|
||||
$(this).on('submit', {url: this.options.url}, function (e) {
|
||||
|
||||
|
|
@ -70,20 +33,50 @@
|
|||
|
||||
form=this;
|
||||
|
||||
if(options.separated_data)
|
||||
{
|
||||
data[options.separated_data]=new FormData($(this)[0]);
|
||||
}
|
||||
/*if($(this).attr('enctype'))
|
||||
{*/
|
||||
if(options.separated_data)
|
||||
{
|
||||
|
||||
data[options.separated_data]=new FormData($(this)[0]);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
data=new FormData($(this)[0]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
xhrFields={
|
||||
withCredentials: true
|
||||
};
|
||||
|
||||
/*}
|
||||
else
|
||||
{
|
||||
data=new FormData($(this)[0]);
|
||||
}
|
||||
|
||||
if(options.separated_data)
|
||||
{
|
||||
|
||||
xhrFields={
|
||||
withCredentials: true
|
||||
};
|
||||
data[options.separated_data]=$(this).serializeArray();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
data=$(this).serializeArray().reduce(function(obj, item) {
|
||||
obj[item.name] = item.value;
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
}
|
||||
|
||||
xhrFields={
|
||||
};
|
||||
|
||||
}*/
|
||||
|
||||
if(!data.hasOwnProperty("csrf_token")) {
|
||||
|
||||
|
|
@ -94,9 +87,12 @@
|
|||
//Hide form and show the time icon
|
||||
|
||||
$(this).find('.error').hide();
|
||||
|
||||
//$(this).hide();
|
||||
$(options.loading).show();
|
||||
|
||||
/*$(this).find('input').prop("disabled", true);
|
||||
$(this).find('select').prop("disabled", true);*/
|
||||
|
||||
if(options.hasOwnProperty("pre_callback")) {
|
||||
|
||||
options.pre_callback(data);
|
||||
|
|
@ -104,25 +100,21 @@
|
|||
}
|
||||
|
||||
//Ajax
|
||||
<<<<<<< HEAD
|
||||
|
||||
$.ajax({
|
||||
=======
|
||||
|
||||
ajax_post={
|
||||
>>>>>>> 811a1691680c070c92096fa1cdc3a061d8745033
|
||||
type: "POST",
|
||||
url: options.url,
|
||||
data: data,
|
||||
encoding: "UTF-8",
|
||||
xhrFields: xhrFields,
|
||||
cache:false,
|
||||
contentType:false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function (data) {
|
||||
|
||||
$(options.loading).hide();
|
||||
|
||||
|
||||
if(data.error) {
|
||||
|
||||
if(!data.hasOwnProperty("error_csrf"))
|
||||
|
|
@ -180,6 +172,8 @@
|
|||
else
|
||||
{
|
||||
|
||||
|
||||
|
||||
// If ok then post successful task.
|
||||
|
||||
if(options.hasOwnProperty("success")) {
|
||||
|
|
@ -206,17 +200,7 @@
|
|||
|
||||
},
|
||||
dataType: 'json'
|
||||
};
|
||||
|
||||
//console.log(xhr);
|
||||
|
||||
if(xhr!=false) {
|
||||
|
||||
ajax_post.xhr=xhr;
|
||||
|
||||
}
|
||||
|
||||
$.ajax(ajax_post);
|
||||
});
|
||||
|
||||
return false;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue