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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:43:45+00:00 2026-06-11T04:43:45+00:00

Here is code that is done in jQuery and the aim is to change

  • 0

Here is code that is done in jQuery and the aim is to change it to javascript. The original code is from here: php proxy

Here is the jQuery to change to javascript:

$(function(){

  // Handle form submit.
  $('#params').submit(function(){
    var proxy = 'ba-simple-proxy.php',
      url = proxy + '?' + $('#params').serialize();

      // Make GET request.
      $.get( url, function(data){

        $('#response')
          .html( '<pre class="brush:xml"/>' )
          .find( 'pre' ) // To make the lines proper and to frame the text.
            .text( data );

      });

    // Prevent default form submit action.
    return false;
  });
});

And below is the same code in javascript, which is not ready yet. The problem is that it is not logical at the moment.

The form bit of html which is not included here calls ajaxcontent(). ajaxcontent() creates the “.html” and “.text” part of the jQuery. JQuery “.find” can be ignored at the moment.

In ajaxcontent() the “pre” tag is created first, then added class “brush:xml” in it. Then “createTextNode” adds the source coude from the page that is asked. This is the “( data )” in jQuery. Here the code fails, since ajax wants to place the information to id=”response”, but ajaxcontent() still needs to do this line “xelement.appendChild(xtext);” to attach the text to “xelement”.

function loadajax() {
    var xmlhttp;
    if (window.XMLHttpRequest) {
        xmlhttp=new XMLHttpRequest();
        }
    else {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 && xmlhttp.status==200) {
            document.getElementById("response").innerHTML=xmlhttp.responseText;
        }
    }

    var urlvar=(document.getElementById("url").value)

    xmlhttp.open("GET","ba-simple-proxy.php&url="+urlvar,true);
    xmlhttp.send();
}

function ajaxcontent() {
    var xelement=document.createElement("pre");
    xelement.className="brush:xml";
    var xtext=document.createTextNode( loadajax() );
    xelement.appendChild(xtext);
}

Any suggestions how to make this work? The jQuery part is a working example but the javascript part is not yet.

  • 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-11T04:43:47+00:00Added an answer on June 11, 2026 at 4:43 am

    OK here is a Ajax POST without jQuery(and a JSFiddle to see it in action, note that this used JSFiddle echo service which requires that the method be POST which is slightly different):

    <input id="url" value="http://google.com/"/>
    <button id="Button">No jQuery POST</button>
    <div id="response" style="border: dashed 1px black;"></div>
    
    document.getElementById('Button').onclick = function() {
        var xmlhttp;
        if (window.XMLHttpRequest) {
            xmlhttp = new XMLHttpRequest();
        }
        else {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("response").innerHTML = "Responce returned!<br/>Data:" + xmlhttp.responseText;
            }
        }
    
        var params = "html=" + escape(document.getElementById("url").value) + "&delay=3";
        xmlhttp.open("POST", "/echo/html/", true);
        xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlhttp.setRequestHeader("Content-length", params.length);
        xmlhttp.setRequestHeader("Connection", "close");
    
        xmlhttp.send(params);
    }
    

    Now this is why things like jQuery are so nice, they hide all of this from the developer 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Node.js can't handle my client code that performs something similar to jQuery/Zepto XHR pattern
I cannot get this to work, here is code that I found in another
Here is my Code that I'm trying to run on Mac OS X: import
Here is the code that doesn't work: Enemy.strength = srand((unsigned)time(NULL)) % 10; Enemy.strength is
Here is my code that adds a line to the grid by pressing the
Here is the code that cause me problem since few hours: TabItem newTab =
Here's my code that is not working: print To: ; my $to=<>; chomp $to;
Here is my code that fails: bool Table::win(const Card &card) { for (int i
Here is the code that I have for my cell of my UITableView: forKeys:[NSArray
I have some code here that uses bitsets to store many 1 bit values

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.