logo
down
shadow

PHP + jQuery: ajax callback not working


PHP + jQuery: ajax callback not working

By : user2954828
Date : November 22 2020, 10:33 AM
Hope that helps error 500 means error in php and in your php don't see defined $mysqli and $result i think here is your problem.
better PHP looks like this but must define connect to DB
code :
<?php
header("Content-type: application/json");
$data = array('result'=>'0');

if ($_SERVER['REQUEST_METHOD'] == 'post' )
{
    $id_pro = $_POST['id_pro'];
    $status = ($_POST['status'] == 0) ? 1 : 0; // if($status==0){$status=1;}else{$status=0;}

    // define $mysqli
    if ($mysqli->query("UPDATE mytable SET online=".$status." WHERE id=".$id_pro." ") === TRUE) {
        $data = array('check'=>'new_class','check_text'=>'new text','result'=>'1');
    }
    // $result->close(); // ????
}

print json_encode($data);


Share : facebook icon twitter icon
JQUERY IE AJAX Success callback not working

JQUERY IE AJAX Success callback not working


By : user2298644
Date : March 29 2020, 07:55 AM
should help you out .html() is ultimately using .innerHTML here, what it seems like is your markup coming back is invalid causing some issues.
If there's something wrong with the markup and you're seeing no error but an empty result, chances are one browser is tolerating that invalid HTML, showing it as best it can, and another browser may discard it entirely...which appears to be what IE is doing to you.
jQuery ajax callback function not working

jQuery ajax callback function not working


By : user2631447
Date : March 29 2020, 07:55 AM
wish of those help First of all thanks @Kamyar and @Brad Christie, to help me solve the problem. while inspecting as Kamyar said to change the format of id to JSON format, i checked the return format for JSON, and found that it was causing the problem, as it was not a valid JSON format. The return JSON format was causing the Problem! return JSON with error,
code :
{"ugdegree":[{"id":31,"specialization":"Dentistry"},{"id":32,"specialization":"Other"},]}
jquery ajax callback is not working

jquery ajax callback is not working


By : user5816964
Date : March 29 2020, 07:55 AM
will help you If you are expecting json response and have jackson jars in your classpath
add @ResponseBody to your method
code :
@RequestMapping(value = "/CIMtrek_Project_Information", method = RequestMethod.POST)
public String getProjectInfotmation(@RequestParam("cerNo") String cerNo,HttpServletRequest request,HttpServletResponse response) throws Exception {
    System.out.println("cerNo : "+cerNo);

    return cerNo;
}
@RequestMapping(value = "/CIMtrek_Project_Information", method = RequestMethod.POST)
public @ResponseBody String getProjectInfotmation(@RequestParam("cerNo") String cerNo,HttpServletRequest request,HttpServletResponse response) throws Exception {
    System.out.println("cerNo : "+cerNo);

    return cerNo;
}
jquery ajax callback not working

jquery ajax callback not working


By : drakzuli
Date : March 29 2020, 07:55 AM
around this issue It was the version I was using of Jquery that messed things up. the CDN that is. Kevin B - thank you much .that really helped. Thank you to all the rest as well who looked into it for me . You guys r amazing, i love this community. i hope i can help back as well ..
later guys. :)
callback in jquery ajax not working when using jquery ajax cache code below

callback in jquery ajax not working when using jquery ajax cache code below


By : gENTRY hANKS
Date : March 29 2020, 07:55 AM
I wish this help you Below is my code and issue is with cache code is not working properly if any ajax call has callback in success. , As discussed in the chatroom I've made some changes in your code :
code :
var localCache = {
  /**
   * timeout for cache in millis
   * @type {number}
   */
  timeout: 30000,
  /** 
   * @type {{_: number, data: {}}}
   **/
  data: {},
  remove: function(url) {
    delete localCache.data[url];
  },
  exist: function(url) {
    return !!localCache.data[url] && ((new Date().getTime() - localCache.data[url]._) < localCache.timeout);
  },
  get: function(url) {
    console.log('Getting in cache for url ' + url);
    return localCache.data[url].data;
  },
  set: function(url, cachedData, callback) {
    localCache.remove(url);
    localCache.data[url] = {
      _: new Date().getTime(),
      data: cachedData
    };
    console.debug('caching data for '+url, cachedData);
    if ($.isFunction(callback)) callback(cachedData);
  }
};

$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
  if (options.cache) {
    var complete = originalOptions.complete || $.noop,
      url = originalOptions.url;
    //remove jQuery cache as we have our own localCache
    options.cache = false;
    options.beforeSend = function() {
      if (localCache.exist(url)) {
        console.log('using cache, NO QUERY');
        complete(localCache.get(url));
        return false;
      }
      console.log('sending query');
      return true;
    };
    options.complete = function(data, textStatus) {
      localCache.set(url, data, complete);
    };
  }
});

function handleAjaxRequests(url, parameters, headers, method, successHandler, options, errorHandler) {
  method = method || "GET";
  headers = headers || {};
  parameters = parameters || {};

  return $.ajax({
    method: method.toUpperCase(),
    url: url,
    cache: true,
    //            async: false,
    data: parameters,
    headers: headers,
    success: successHandler,
    error: errorHandler,
  });
}

handleAjaxRequests('/echo/json/', {p1: 'hey'}, null, 'POST', function(data){console.log('first success without cache', data);});

setTimeout(function(){
handleAjaxRequests('/echo/json/', {p1: 'hey'}, null, 'POST', function(data){console.log('success! with cache hopefully', data);});
}, 2000);
function handleAjaxRequests(url, parameters, headers, method, successHandler, options, errorHandler) {
  method = method || "GET";
  headers = headers || {};
  parameters = parameters || {};

  return $.ajax({
    method: method.toUpperCase(),
    url: url,
    cache: true,
    //            async: false,
    data: parameters,
    headers: headers,
    success: (function(handler, opt) {
      return function( /*Anything*/ data, /*String*/ textStatus, /*jqXHR*/ jqXHR) {
        console.log('hi');
        handler(data, opt);
        console.log('bye');
      };
    })(successHandler, options),
    error: (function(handler, opt) {
      return function( /*jqXHR*/ jqXHR, /*String*/ textStatus, /*String*/ errorThrown) {
        console.log('ouch');
        handler(errorThrown);
      };
    })(errorHandler, options),
  });
}
function handleAjaxRequests(url, parameters, headers, method, successHandler, options, errorHandler) {
  method = method || "GET";
  headers = headers || {};
  parameters = parameters || {};

  return $.ajax({
    method: method.toUpperCase(),
    url: url,
    cache: true,
    //            async: false,
    data: parameters,
    headers: headers,
    complete: (function(handler, opt) {
      return function( /*Anything*/ data, /*String*/ textStatus, /*jqXHR*/ jqXHR) {
        console.log('hi');
        handler(data, opt);
        console.log('bye');
      };
    })(successHandler, options),
    error: (function(handler, opt) {
      return function( /*jqXHR*/ jqXHR, /*String*/ textStatus, /*String*/ errorThrown) {
        console.log('ouch');
        handler(errorThrown);
      };
    })(errorHandler, options),
  });
}
Related Posts Related Posts :
  • Curl PHP cannot display amazon
  • Symfony, getters and setters vs magic methods
  • Using 'continue' PHP instruction outside the loop
  • AJAX POST return data not appearing
  • Can I query relations using an INNER JOIN instead of two queries in Eloquent?
  • Looping through dynamic form fields and inserting into database
  • My php code can't select mysql auto_increment value
  • Store Angularjs form data in database using php
  • I want to run my sh file continuously even if I close my Putty connection
  • file_get_contents equivalent for gzipped files
  • Include PHP file with jQuery
  • php curl headers do not return from website?
  • How to find out, if facebook ID is a user, group or page
  • Connect webhost database to android database
  • preg_match get div content with class
  • Upload multiple files in Laravel 4
  • Count array numbers in multidimensional array
  • PHP Date diff with a difference
  • Search Customer by custom field in Netsuite
  • Is it possible to hide/encode/encrypt php source code and let others have the system?
  • list items to be displayed using php code and array
  • check if row exists mysqli
  • PHP errors loading MySQL
  • setup PostgreSQL with Laravel in MAMP
  • PHP - CodeIgniter Notifications
  • Encrypting a password column in a SQL database
  • New to PHP, trying to extract information from another website
  • JavaScript AmChart to Image for Email
  • Is javascript validation enough to keep my forms secure?
  • Regex extract variables from [shortcode]
  • Download a .mp3 link and save it to computer with PHP
  • Error with the ereg_replace
  • Getting the fields attached to a bundle of an entity in Drupal
  • Php how to check multiple times (within `foreach`) if values from array exists in mysql?
  • MySQL and PHP parsing strange string
  • Pull specific data from multidimensional associative array
  • How to get the original URI extension using PHP Tonic?
  • Upload videos and images from Android to PHP server?
  • Unset a multidimensional array with another multidimensional array with values than key
  • Calling a user e-mail to add to a mailto link PHP
  • Why is override_function coming back as an undefined function
  • PHP mySQLi_fetch_all: iterate through each row
  • Using pow in php
  • What's wrong with my PHP Script? T_String issue
  • how to call a function of another file without including that file
  • is_rgb function in php
  • transform the numbers to letters using php
  • How to catch an exception from another class method PHP
  • PHP exec is blocked by ISP
  • PHP4 to PHP5 migration character encoding. latin1 vs utf8
  • Begin Transaction not defined
  • How much harm can a user do with xss on a page unique to them?
  • How to import data from a php file to javascript variable
  • PHP and Javascript - log complete workflow
  • When I echo !!! 0 it gives me a strange result
  • jquery ajax post dies after submit
  • How to upload file with curl on sftp server
  • Advanced search using a text input to search through only one category
  • Why do I get "Non-static method App\Models\Category::products() should not be called statically" in laravel
  • Stop notices from undefined indexes in arrays
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org