Answer the question
In order to leave comments, you need to log in
Ajax request not sent?
Good evening, to the point:
request:
$(document).ready(function () {
$('.on-tree').click(function () {
var mySponsorNumber = $(this).attr('id'),
url = '/all/add_item_tree.php';
$.ajax({
type: "POST",
url: url,
data: {treeElm: mySponsorNumber},
dataType: 'json',
success: function (result) {
if (result) {
alert('ok');
console.log(result);
} else {
alert('error');
}
},
error: function () {
alert('error2');
}
});
});
});
<?php
session_start();
require_once("mysql/db.php");
$itemTree = $_POST['treeElm'];
if($itemTree){
$out = array(
'testAjax' => $itemTree
);
}else{
$out = array(
'testAjax' => 'syka blyat'
);
}
header('Content-Type: text/json; charset=utf-8');
echo json_encode($out);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question