Skip to content

Commit

Permalink
Fix: double ajax request
Browse files Browse the repository at this point in the history
  • Loading branch information
idoalit committed Oct 1, 2018
1 parent 0f31b02 commit 45c48ca
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions js/updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jQuery.extend({
* @param string strURL : URL of AJAX request
* @return void
*/
jQuery.fn.simbioAJAX = function(strURL, params)
jQuery.fn.simbioAJAX = async function(strURL, params)
{
var options = {
method: 'get',
Expand Down Expand Up @@ -85,23 +85,20 @@ jQuery.fn.simbioAJAX = function(strURL, params)
/* End */
})

// send AJAX request
/* Modified by Drajat Hasan */
// Get response code
var ajaxResponseCode = $.ajax({
type : options.method, url : strURL,
data : options.addData, async: false }).status;
var ajaxResponse;
try {
ajaxResponse = await $.ajax({
type : options.method, url : strURL,
data : options.addData, async: false })

// If success
if (ajaxResponseCode == 200) {
var ajaxResponse = $.ajax({
type : options.method, url : strURL,
data : options.addData, async: false }).responseText;
} else {
// Hide same error message in #mainContent
var ajaxResponse = '';
}
/* End */
// clear error message
if (loader.html().indexOf('Error') > -1) {
loader.html(' ')
}
loader.removeAttr('style')
} catch (err) {
console.error(err)
}

// add to elements
if (options.insertMode == 'before') {
Expand Down

0 comments on commit 45c48ca

Please sign in to comment.