Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8945091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:10:20+00:00 2026-06-15T12:10:20+00:00

Possible Duplicate: Calling a JavaScript function returned from a Ajax response var url =

  • 0

Possible Duplicate:
Calling a JavaScript function returned from a Ajax response

var url = "showpdf.php";
$.ajax({
    type: "post",
    url: url,
    data:    {academic:academic,uni:uni,course:course,lan:lan,sem:sem,subject:subject,type:type,clz:clz},
    success: function(response)
    {
        alert(response);
        document.getElementById("alldata").innerHTML = response;

    }
});

inside response i have bellow html code with simple JavaScript function

<label onclick="popup()"> clickme </label>
<script>
function popup()
{
  alert("hello");
}
</script>

here, this popup()function is not working please help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:10:21+00:00Added an answer on June 15, 2026 at 12:10 pm

    The problem is you expect that Javascript contained within an ajax response is executed. This isn’t the case, the browser doesn’t execute any Javascript contained within ajax responses. It might be possible to try to parse out the Javascript and execute it in some way, such as eval() but that would be nasty and not a good idea. Using eval() you also have to consider that it will only accept valid Javascript, so you couldn’t just pass your response to it because that includes some HTML.

    A possible solution could be to have the popup() function already defined in the page or an external Javascript file, and to assign the click handler after you add the HTML to the DOM.

    For example:

    function popup()
    {
        alert(this.id);
    }
    
    
    document.getElementById("alldata").innerHTML = response;
    document.getElementById("myNewLabel").onclick = popup;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: calling ASP function from javascript okay running this code : <script type=text/javascript>
Possible Duplicate: How to return AJAX response Text? I'm calling a javascript method which
Possible Duplicate: Iframe Function Calling From Iframe to parent page javascript function I have
Possible Duplicate: Calling PHP Function within Javascript I have a small JavaScript code in
Possible Duplicate: Calling Python from JavaScript I have a test.py and test.js . I
Possible Duplicate: Calling A Button OnClick from a function I want to do button
Possible Duplicate: Calling PHP from Java I was wondering how I could run PHP
Possible Duplicate: C++ virtual function from constructor Calling virtual functions inside constructors This question
Possible Duplicate: Calling a JavaScript function named in a variable I want to use
Possible Duplicate: Javascript closure inside loops - simple practical example Calling setTimeout function within

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.