2

I'm using the following code lines in Javascript in order to return a value(String) from an AJAX response:

function ForumNameByForumID(ID) {
    var forum_name_topic_id = "";
    var params = JSON.stringify({ forumid: ID });

    $.ajax(
{
    type: "POST",
    dataType: "json",
    data: params,
    contentType: "application/json; charset=utf-8",
    url: "WebService1.asmx/ForumNameByForumID",
    success: function Process_Result(data) {
        forum_name_topic_id = data.d.toString();
    },
    error: function Process_Error() {  }

});
    return forum_name_topic_id;
}

but it returns an empty string..

Nutz
  • 79
  • 2
  • 11
  • See also: [Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference](http://stackoverflow.com/questions/23667086/why-is-my-variable-unaltered-after-i-modify-it-inside-of-a-function-asynchron) – James Thorpe May 05 '17 at 16:12

0 Answers0