Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

XMLHttpRequest return the page code


ts_ecommerce

Recommended Posts

Hi:

 

I'm working on adminitrative module that works with ajax. I have a simple php with "echo functions" and a javascript file that call that .php. I do this other times, but with oscommerce the "responseText" is the current page html code (with the changes).

 

EDIT with some code:

 

Admin page:

<a class="refresh" href="#" title="refresh" onclick="fajax();return false;">Refresh</a>
<div id="div_refresh">TEXT</div>

 

JavaScript function:

function fajax(){
   var content_div_id = 'div_refresh';
   contenedor = document.getElementById(content_div_id);
   if(contenedor == null) return false;
   contenedor.innerHTML = 'Loading...';
   var source = 'folder/ajaxfunc.php'; //That folder in 'admin/includes'
   var xhr = "new XMLHttpRequest";
   xhr.open('GET', source, false);
   xhr.send('');
   contenedor.innerHTML = xhr.responseText;
   return xhr.responseText;
}

 

PHP file (ajaxfunc):

<?php
echo "REFRESH!!!";
?>

 

And, like I said, the "xhr.responseText" returns the current page html code with the changes, but I only want the php "echo". I don't understand. Another echo?

 

Does anyone have any idea that could be happening?

 

Thanks for your time and sorry for my english.

Edited by ts_ecommerce
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...