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 8723287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:35:45+00:00 2026-06-13T07:35:45+00:00

I want a javascript script to be echoed when a condition is true, the

  • 0

I want a javascript script to be echoed when a condition is true,
the file where this script is on is called through ajax by another page
and for some reason it wont echo the <script>...</script> part.
If i put a regular string there it works but it just wont echo javascript.

$max = $int + 10;
  if($max >= $num_rows){
    $end = "<script>var end=1</script>";
  } else {
    $end = "<script>var end=0</script>";
  }

 echo $end;

ajax:
function onScroll(event) {
// Check if we’re within 100 pixels of the bottom edge of the broser window.
var closeToBottom = ($(window).scrollTop() + $(window).height() > $(document).height() – 100);

          if(closeToBottom) {

            if(end==0){
             // GET THE 10 NEXT ITEMS;
              if (window.XMLHttpRequest)
                 {// code for IE7+, Firefox, Chrome, Opera, Safari
                 xmlhttp=new XMLHttpRequest();
                 }
               else
                 {// code for IE6, IE5
                 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                 }
               xmlhttp.onreadystatechange=function()
                 {
                 if (xmlhttp.readyState==4 && xmlhttp.status==200)
                   {
                   //document.getElementById("tiles").innerHTML=xmlhttp.responseText;




                         $('#tiles').append(innerHTML=xmlhttp.responseText);
                         int = int+10;
                         // Clear our previous layout handler.
                         if(handler) handler.wookmarkClear();

                         // Create a new layout handler.
                         handler = $('#tiles li');
                         handler.wookmark(options);


                         $(function() {
                            // Select all links whose attribute rel starts with lightbox
                            $('a[rel^=lightbox]').lightBox();
                         });


                           FB.XFBML.parse();

                   }

                 }
            } 
               $.extend({
                    getUrlVars: function(){
                      var vars = [], hash;
                      var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
                      for(var i = 0; i < hashes.length; i++)
                      {
                        hash = hashes[i].split('=');
                        vars.push(hash[0]);
                        vars[hash[0]] = hash[1];
                      }
                      return vars;
                    },
                    getUrlVar: function(name){
                      return $.getUrlVars()[name];
                    }
                  });

                  var request = $.getUrlVar('item');

                  if(request!=null){
                    var allR = "?int="+int+"&item="+request;
                  } else {
                    var allR = "?int="+int;
                  }


               xmlhttp.open("GET","tiles.php"+allR,true);
               xmlhttp.send();


             }

        };

Can anyone solve this?
Thx in advance.

  • 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-13T07:35:46+00:00Added an answer on June 13, 2026 at 7:35 am

    The thing is you have to go through the DOM tree of the document bit you download through Ajax and manually evaluate it using eval, because for security reasons browsers do not automatically parse and run the JavaScript code embedded through remote calls for you.

    You can do something like this:

    var scripts = domElement.getElementsByTagName("script");
    for (var i = 0; i < scripts; i ++) {
        eval(scripts[i].text);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to redirect to another page when a checkbox is clicked. <script type=text/javascript><!--
How to implement timeout in this code: Response.Write(@<script language='javascript'>alert('some alert');</script>); Response.Redirect(Request.ApplicationPath); I want to
This php code is called through ajax from javascript and should return a numeric
I want my JavaScript that's referenced through <script> tags, my css, and various graphic
I want the following javascript code to be echoed in a PHP class file.
I'm attempting to write a very basic script using javascript. What I want to
I want increment #hidtr value in jquery. <script type=text/javascript> $('#hidtr').val(parseInt($('#hidtr').val()+1)); alert($('#hidtr').val()); </script>
For the following code <script type=text/javascript> $(document).ready(function(){ $(#erase).click(function(){ confirm('Are you sure you want to
I want to run a javascript one time. I tried using a script from
JavaScript. I want to create simple script, that will be resize loaded image using

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.