Accessing the PHP class with AJAX

0

I have the file.js file in the folder:

folder1\folder-xpto\js\c3-0.4.11\file.js

This file has the following script AJAX :

$.ajax({
    type : 'post',
    url : 'controller/classX.php',
    dataType : 'html',
    data : {
        var1 : 12,
        varId : 87
    },
    beforeSend : function() {
    },
    complete : function() {
    },
    success : function(options) {
        alert(options);
    },
    error : function(xhr, er) {
    }
});

And I want to access the file classX.php that is here:

folder1\folder2\classX.php

In the file classX.php I have the following script to validate and get the value sent:

    if (isset ( $_POST ['varId'] )) {
        echo 'recebido';
// ...
    }

I've tried several ways, putting './' or '../' , etc, in the URL, but I can not.

Does anyone know how I can do this?

    
asked by anonymous 31.10.2017 / 15:43

1 answer

0
   $.ajax({
    type : 'post',
    url : '../folder2/controller/classX.php',
    dataType : 'html',
    data : {
        var1 : 12,
        varId : 87
    },
    beforeSend : function() {
    },
    complete : function() {
    },
    success : function(options) {
        alert(options);
    },
    error : function(xhr, er) {
    }
});
    
01.11.2017 / 14:32