Tag: 嵌套函数

从javascript中的嵌套函数返回

我正在尝试使用jquery的ajax函数来从我的ajax.php文件中获取一些信息。 码: function ajaxIt(dataLine){ $.ajax({ type: “POST”, url: “ajax.php”, data: “ajax=true&”+dataLine, success: function(msg){ console.log(“[AjaxIt]: “+dataLine+” returned “+msg); return msg; } }); } if(ajaxIt(“action=loggedIn”)==”1″){ console.log(“Logged In”); loggedIn=true; initiate2(); } 问题是我无法获得成功函数一直返回到ajaxIt函数。 任何人都可以说明我可以做些什么吗? 谢谢。

需要有关嵌套jquery函数的帮助

请在下面找到我的代码。 我的问题是我内部的jQuery.get()没有被执行。 有人可以帮我解决这个问题吗? jQuery(document).ready(function() { $(‘.error’).hide(); $(“.button”).click(function() { // validate and process form here $(‘.error’).hide(); var zipCode = $(“input#name”).val(); if (zipCode == “”) { $(“label#name_error”).show(); $(“input#name”).focus(); return false; } var key = ‘ac9c073a8e025308101307’; var noOfDays = 5; var url = ‘http://www.worldweatheronline.com/feed/weather.ashx?q=’ + zipCode + ‘&format=json&num_of_days=’ + noOfDays + ‘&key=’ + key; alert(url); jQuery.get(url, function(test) { […]