我嵌套了在ie7中无效的ajax调用。它们在Firefox中运行良好。 根本没有输入第二个$ .post中的服务文件。换句话说,如果我的服务文件的第一行是print'hello';我从来没有看到它...即使我在$ .post中为响应添加了console.log。我在其他地方也见过这个问题...... http://www.mail-archive.com/jquery-en@googlegroups.com/msg34270.html
/**
* Listener for saving page content to the database and an associative flat file
*
* @return void
*/
$(document).ready(function()
{
// Listen for the save button click
$('#save-button').live('click', function()
{
// Disable the save button just in case of repeat submits
$('#save-button').attr('disabled', 'disabled');
// Loop through the micro template children
$('#micro-template').children().each(function()
{
var id = $(this).attr('id');
// Remove random content from the DOM for this node
$(this).find('.random-content').remove();
// Remove divs that don't matter (contains edit buttons)
$(this).find('.' + id).remove();
// Remove unwanted area (contains edit buttons)
$(this).find('.remove').remove();
// Remove firebug div
$(this).find('#_firebugConsole').remove();
// Remove the class definition for the current item
$(this).removeAttr('class');
// Loop through the children's children
$(this).children().each(function()
{
// Remove mouseover actions
$(this).removeAttr('onmouseover');
// Remove divs with no data
if ($(this).html() == '')
{
$(this).remove();
}
// Remove empty styles
if ($(this).attr('style') == '')
{
$(this).removeAttr('style');
}
});
// Get the DOM HTML for this node
var html = $(this).html();
// Get the properties for the page
$.post('../services/getsession.php', function(session)
{
// Setup the content result
var obj = {
obj: session,
data: html,
microdiv: id
};
// Insert the content result for the node into the databse
$.post('../services/addContent.php', obj, function(response)
{
// Check for errors
if (response != 'success')
{
var msg = '<p class="user-error"><b>Error</b><br />Failed to add your content. Reason: ' + response + '</p>';
$('#micro-template').append(msg);
var $err = $('#micro-template').find('.user-message');
if ($err.is(':visible'))
{
// Slides out a DOM element with the class 'user-message' after 2 seconds
$(this).delay(2000,function(){
$err.slideUp('slow');
self.close();
});
}
return false;
}
else
{
$(opener.document).find('#step-three-div').hide();
$(opener.document).find('#step-one-div').show();
$(opener.document).find('form').css('width', '70%');
$(opener.document).find('form').css('height', '460px');
var $err = $('#micro-template').find('.user-message');
if (!$err.is(':visible'))
{
var msg = '<p class="user-message"><b>Information</b><br />Successfully added your content</p>';
$('#micro-template').append(msg);
var $err = $('#micro-template').find('.user-message');
if ($err.is(':visible'))
{
// Slides out a DOM element with the class 'user-message' after 2 seconds
$(this).delay(2000,function(){
$err.slideUp('slow');
self.close();
});
}
}
}
});
});
});
});
});
答案 0 :(得分:0)
你没有在你的第一个ajax调用中传递第二个参数。它应该是
$.post('../services/getsession.php', {}, function(session){});
还尝试在函数中放入第二个ajax调用,并在第一个ajax完成后调用该函数。
$.post('../services/getsession.php', {}, function(session){
var obj = {
obj: session,
data: html,
microdiv: id
};
mysecondAjaxCall(obj);
});
如果它没有解决问题,那么在调用函数mysecondAjaxCall()之前放置延迟。