I want to convert my $.post
call to $.ajax
call because I need to clean the cache for every call.
My $.post
call is as follows:
$.post("test",
function(data) {
$("#test").html(data);
initTest();
}
).success(function(){
$('.box1').hide("slide", {direction: "left"}, 1000);
$('.box3').show("slide", {direction: "right"}, 1000);
});
I tried this but it doesn't work...
$.ajax({
type: "POST",
url: "test",
success: function (data) {
$("#test").html(data);
$('.box1').hide("slide", {direction: "left"}, 1000);
$('.box3').show("slide", {direction: "right"}, 1000);
},
dataType: "json",
cache: false
});
$.ajax({
method:"POST",
url : "test.php",
success : function(data) {
$("#test").html(data);
initTest();
$('.box1').hide("slide", {direction: "left"}, 1000);
$('.box3').show("slide", {direction: "right"}, 1000);
},
cache : false
});
UPDATE
I think you have problem in parsing data. In $.post
by default is html dataType
. In $.ajax
call you changed it on "json". If no json is responsed so you have parse error and success handler dont call.