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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:22:17+00:00 2026-06-13T03:22:17+00:00

I wrote a cgi-script with c++ to return the query-string back to the requesting

  • 0

I wrote a cgi-script with c++ to return the query-string back to the requesting ajax object.
I also write the query-string in a file in order to see if the cgi script works correctly.
But when I ask in the html document for the response Text to be shown in a messagebox i get a blank message.

here is my code:

js:

<script type = "text/javascript">

var XMLHttp;
if(navigator.appName == "Microsoft Internet Explorer") {
XMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
} else {
XMLHttp = new XMLHttpRequest();
}

function getresponse () {
XMLHttp.open
("GET", "http://localhost/cgi-bin/AJAXTest?" + "fname=" +
document.getElementById('fname').value + "&sname=" + 
document.getElementById('sname').value,true);
XMLHttp.send(null);
}

XMLHttp.onreadystatechange=function(){
if(XMLHttp.readyState == 4)
{
document.getElementById('response_area').innerHTML +=  XMLHttp.readyState;
var x= XMLHttp.responseText
alert(x)
} 
}
</script>

First Names(s)<input onkeydown = "javascript: getresponse ()" 
id="fname" name="name"> <br>

Surname<input onkeydown = "javascript: getresponse();" id="sname">

<div id = "response_area">

</div>

C++:

int main() {

QFile log("log.txt");
if(!log.open(QIODevice::WriteOnly | QIODevice::Text))
{
    return 1;
}
QTextStream outLog(&log);
QString QUERY_STRING= getenv("QUERY_STRING");

//if(QUERY_STRING!=NULL)
//{

    cout<<"Content-type: text/plain\n\n"
        <<"The Query String is: "
        << QUERY_STRING.toStdString()<< "\n";
    outLog<<"Content-type: text/plain\n\n"
          <<"The Query String is: "
          <<QUERY_STRING<<endl;

//}

return 0;
}

I’m happy about every advice what to do!

EDIT: the output to my logfile works just fine:

Content-type: text/plain

The Query String is: fname=hello&sname=world

I just noticed that if i open it with IE8 i get the query-string. But only on the first “keydown” after that IE does nothing.

  • 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-13T03:22:21+00:00Added an answer on June 13, 2026 at 3:22 am

    My problem had nothing to do with the code…
    I was testing my script on the local IIS7 and I opened the html-page with double-clicking on the file. But you have to open the webpage via browser (localhost/mypage.htm) because otherwise for the browser the html and the executable have different origins. which is not allowed.

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

Sidebar

Related Questions

How would I write a Perl CGI script that receives a file via a
I'm trying to write a Perl CGI script to handle XML-RPC requests, in which
I wrote a PHP script that retrieves values from a MySQL Query. I used
I'm writing a python CGI script that will query a MySQL database. I'm using
I have a CGI script run by Hiawatha web server that needs to return
I can't seem to open and write to a text file from my CGI
I want to execute a Python CGI Script within a .shtml file, but I
I want to write either a perl (CGI) or php script on a server
I am about to write a Perl CGI script that is to be deployed
I am trying to write out a python cgi script that will redirect me

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.