怎么用$.getJSON的返回值赋值给变量?

WBOY
Release: 2016-06-20 12:34:00
Original
1547 people have browsed it

各位大神,我的原程序是这样的:
 $("#item>a[rel=copylink]").zclip({
path: "/zmgjw/js/ZeroClipboard.swf",
copy: function(){
var data = "aid="+arcId;
 $.getJSON("/plus/ajax_copy.php",data, function(re_data){
alert(re_data);
 })}
});

 $.getJSON后,我用alert能返回值,但我想把返回的值re_data再赋给变量VAR result,以便让ZCLIP程序调用。我该怎么写?谢谢!!


回复讨论(解决方案)

$.ajaxSetup({async:false}); //指定 ajax 以同步方式工作var result;$("#item>a[rel=copylink]").zclip({  path: "/zmgjw/js/ZeroClipboard.swf",  copy: function(){  var data = "aid="+arcId;  $.getJSON("/plus/ajax_copy.php",data, function(re_data){    result = re_data;  })}});
Copy after login

非常感谢!已经搞定!谢谢!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!