Learn, Share, Build

263
September 28, 2017, at 7:15 PM

I run a $.post request in jQuery to a server, the php code runs correctly but in firefox the post request throw a error and jump in the .fail function. in chrome it works perfect but in firefox not.

$.post(url, {
    products: JSON.stringify(tempArray)
  },
  function(data) {
  }).done(function() {
  sendingCount++;
}).fail(function() {
  alert("error");
});

why call firefox a error and chrome not ? and data works completely on the server site

Answer 1

Try something like the below:

var products = JSON.stringify(tempArray);
$.ajax({
  type: "POST",
  url: url,
  data: {"products": products}
}).success(function(data,textStatus,jqXHR){
 console.log(data);
 sendingCount++;
}).fail(function(jqXHR,textStatus,errorThrown) {
 console.log(errorThrown);
});

When developing a jQuery AJAX JavaScript script use the Firefox network monitor or the Chrome network panel to gain insight into XHR requests and the server response.

Answer 2

ok this works for me:

i change the post function to the ajax function

$.ajax({
            type: "POST",
            headers: {
                "Content-Type": "application/json;charset=utf-8"
            },
            url: url,
            data: JSON.stringify(tempArray)
        }).done(function(data){
            console.log('success');
        }).error(function(data){
            console.log('error');
        });
Rent Charter Buses Company
READ ALSO
Learn, Share, Build

Learn, Share, Build

I have a XML file that looks like this:

184
Learn, Share, Build

Learn, Share, Build

I have questionWhy i can't upload files size more than 5G ?

212
Learn, Share, Build

Learn, Share, Build

Please I'm trying to fix issue on wordpress relating to generating video thumbnails from videos for a self hosted siteThe theme I use apparently doesn't support, tried using Video Embed & Thumbnail Generator plugin but it still doesn't give

180