admin管理员组文章数量:1332383
$('.updateDescriptionProduct').click( function() {
if ( updateProductDescription(productID, description) == 'true') {
alert('success!');
} else {
alert('did not update');
}
});
function updateProductDescription(productID, description) {
$.ajax({
url: '/index.php/updateProductDescription',
global: false,
type: 'POST',
data: ({productID: productID, description: description}),
dataType: 'html',
async:false,
success: function(msg){
alert(msg);
return msg;
}
});
}
The function itself says true, but my click
event es back as undefined
.
$('.updateDescriptionProduct').click( function() {
if ( updateProductDescription(productID, description) == 'true') {
alert('success!');
} else {
alert('did not update');
}
});
function updateProductDescription(productID, description) {
$.ajax({
url: '/index.php/updateProductDescription',
global: false,
type: 'POST',
data: ({productID: productID, description: description}),
dataType: 'html',
async:false,
success: function(msg){
alert(msg);
return msg;
}
});
}
The function itself says true, but my click
event es back as undefined
.
- What exactly are you trying to do? – Jamie Wong Commented Aug 15, 2010 at 1:05
1 Answer
Reset to default 10the return
applies to the callback. Try setting a variable in the initial function and setting the value in the callback, then returning it?
function updateProductDescription(productID, description) {
var ret = false;
$.ajax({
url: '/index.php/updateProductDescription',
global: false,
type: 'POST',
data: ({productID: productID, description: description}),
dataType: 'html',
async:false,
success: function(msg){
ret = msg;
}
});
return ret;
}
I haven't ever done an async
call but it seems this should work. Let me know if it doesn't.
本文标签: javascriptjQuery Ajax returns undefinedStack Overflow
版权声明:本文标题:javascript - jQuery Ajax returns undefined - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742294805a2448508.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论