I have two functions to submit to different sets of data to the same page. One function works fine, but the other doesn’t send the post data. Here is the code:
function sortManufacturer() {
showLoading();
var orderList = '';
orderedNodes = document.getElementById("sortable_list").getElementsByTagName("li");
for (var i=0;i < orderedNodes.length;i++) {
orderList += orderedNodes[i].getAttribute('recordid') + ',';
}
$.post( 'save_sort_order.php', {type:'manufacturer', order: orderList},
function() {
hideLoading();
$( ".saved" ).dialog( "open" );
}
);}
function editManufacturer() {
showLoading();
var fields = $("form#edit_manufacturer").serializeArray();
$.post( 'save_sort_order.php', {manActive: fields},
function(data) {
hideLoading();
$( ".saved" ).dialog( "open" );
}
);}
This doesn’t work either, no alert saying success and no alert throwing an error. Just reloads the page.:
function editManufacturer() {
$.ajax({
type: "POST",
url: "save_sort_order.php",
data: "hey",
success: function(){
alert("success");
},
error: function(request, status, error) {
var result = JSON.parse(request.responseText);
alert(result.message);
}
});
}
No post data is being sent in Firebug under the Net panel. The first function works fine, the second is the one not being sent. If I put alert(“after”); after the $.post right before the closing } of the function, it works fine.
I would start by adding an
error handlerto$.post, see the message it returns.Also look at
firebug net panelto see the request and responsehttp://getfirebug.com/network
http://getfirebug.com/wiki/index.php/Net_Panel
edit
refer thread:-
jQuery AJAX error handling
change your ajax syntax for how its give over there. its more readable that way.
also replace error handler with