这是我的代码,请我第一次做AJAX,请帮我编写代码。
%// Vectorize : "g(:, i) = g(:, i) - sum(log(sigma(i, :)))"
parte1 = bsxfun(@minus,g,sum(log(sigma),2).'); %//'
%// Vectorize : "bsxfun(@minus, x, mu(i, :)).^2"
parte2_1 = bsxfun(@minus,x,permute(mu,[3 2 1])).^2;
%// Vectorize : "bsxfun(@rdivide, ...*sigma(i, :).^2)"
parte2 = bsxfun(@rdivide,parte2_1,2*permute(sigma,[3 2 1]).^2);
%// Squeeze in dimensions of the BSXFUN extended array and subtract from parte1
g = parte1 - squeeze(sum(parte2,2));
MY.PHP页面内容
$("#ok").on('submit', function (e) {
e.preventDefault();
$.ajax({
url: '/final/my.php',
dataType : 'json',
type: 'post',
data: $(this).serialize(),
timeout: 5000,
success: function(data) {
// I don't have what to add here to recieve that $arr JSON object from my.php page
},
error: function(data) {
alert('An error occurred');
}
});
});