Tag Archives: function

How can I return a variable from a $.getJSON function

Questions: I want to return StudentId to use elsewhere outside of the scope of the $.getJSON() j.getJSON(url, data, function(result) { var studentId = result.Something; }); //use studentId here I would imagine this has to do with scoping, but it doesn’t seem to work the same way c# does Answers: Yeah, my previous answer does not… Read More »

jQuery click function doesn't work after ajax call? [duplicate]

Questions: This question already has an answer here: Event binding on dynamically created elements? 19 answers Answers: The problem is that .click only works for elements already on the page. You have to use something like on if you are wiring up future elements $(“#LangTable”).on(“click”,”.deletelanguage”, function(){ alert(“success”); }); Questions: Answers: When you use $(‘.deletelanguage’).click() to… Read More »

$http.get(…).success is not a function

Questions: i have this code: app.controller(‘MainCtrl’, function ($scope, $http){ $http.get(‘api/url-api’) .success(function (data, status, headers, config){ } } In my local enviroment, works ok, but in a server, return this error: TypeError: $http.get(…).success is not a function Any ideas? Thanks Answers: The .success syntax was correct up to Angular v1.4.3. For versions up to Angular v.1.6,… Read More »

How to pass a callback as a parameter into another function

Questions: I’m new to ajax and callback functions, please forgive me if i get the concepts all wrong. Problem: Could i send a callbackfunction as a parameter to another function that will execute the callback? function firstFunction(){ //some code //a callback function is written for $.post() to execute secondFunction(“var1″,”var2”,callbackfunction); } function secondFunction(var1, var2, callbackfunction) {… Read More »

How to use source: function()… and AJAX in JQuery UI autocomplete

Questions: I need a little bit help with JQuery UI Autocomplete. I want my textfield (.suggest-user) display names from an AJAX request. This is what I have: jQuery(“input.suggest-user”).autocomplete({ source : function(request, response) { var name = jQuery(“input.suggest-user”).val(); jQuery.get(“usernames.action?query=” + name, function(data) { console.log(data); // Ok, I get the data. Data looks like that: test =… Read More »

jQuery ajax error function

Questions: I have an ajax call passing data to a page which then returns a value. I have retrieved the successful call from the page but i have coded it so that it raises an error in the asp. How do i retrieve that error from the jquery? For example: cache: false, url: “addInterview_Code.asp”, type:… Read More »