1

I am sending data with ajax in Prestashop 1.6 with this function:

 function setWineoCarrierMethod(method_id){
      var methodData = {
        'ajax_function': 'set_wineocarrier_method',
        'method_id': method_id
      };
      var jsonData = JSON.stringify(methodData);
      if (method_id) {
        $.ajax({
          url: baseDir + '/modules/wineocarrier/ajax.php',
                type: 'post',
                data: jsonData,
                dataType: 'json',
          success: function(json) {
            console.log(JSON.stringify(json));
            console.log("successfull request");
          },
          error: function(json) {
            console.log(JSON.stringify(json));
            console.log("error in the request");
          }
        });
      }
    };

I want to read the data in the ajax.php file using:

 $data = $_POST['data'];

 $data2 = $_REQUEST['data'];

Both are returning lots of html and there is a notice:

Notice: Undefined index: data in ... line 12 which is $data = $_POST['data'];

Any idea how to handle this?

devpro
  • 16,184
  • 3
  • 27
  • 38
Henry Lynx
  • 1,099
  • 1
  • 19
  • 41

0 Answers0