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

  • Home
  • SEARCH
  • 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 9146597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:47:14+00:00 2026-06-17T10:47:14+00:00

I have written a javascript to post data to a server. This seems to

  • 0

I have written a javascript to post data to a server. This seems to be working but I’m having trouble catching the servers response in iframe. I want to catch the servers response in iframe or in a datastream without forwarding to a other page or refreshing but i will settle with just stopping the page from being forwarded or refreshed.

I have tried adding target="my_frame" to the button and the form attributes but it doesn’t seem to work.

My code, I slightly modified my code for presentation:

 <html>
  <head>

    <title>post</title>

  </head>
  <body>

<script language="javascript">

   var myDictionary = [];
    myDictionary["username"] = "stackoverflow";
    myDictionary["password"] = "mypassword";


function post(dictionary, url, method) {
    method = method || "post"; 

    var form = document.createElement("form");
    form.setAttribute("method", method);
    form.setAttribute("action", url);

    for (key in dictionary) {
        var hiddenField = document.createElement("input");
        hiddenField.setAttribute("type", "hidden"); 
        hiddenField.setAttribute("name", key);
        hiddenField.setAttribute("value", dictionary[key]);
        form.appendChild(hiddenField); 
    }

    document.body.appendChild(form); 
    form.submit();
}
</script>

<input type="button" target="my_frame" value="Submit" onclick="javascript:post(myDictionary, 'http://www.website.com/register/registernow');" />

    <iframe name="my_frame" src="">

  </body>
</html>

Thanks for reading and for all replies.

  • 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-17T10:47:15+00:00Added an answer on June 17, 2026 at 10:47 am

    What you are looking for is an Ajax POST.

    You don’t need to create a form and submit it, instead you need XMLHttpRequest, or if you are using jquery you can use $.post or $.ajax.

    See for example http://blog.mgechev.com/2011/07/21/ajax-jquery-beginners/

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

Sidebar

Related Questions

I have this function written: <script type="text/javascript"> function getStartDate(value) { $.post("gSearch.php", {dateSearch:value}, function(data){ $('#results').html(data);
(this is my fist post) I have written a PHP-script to enter a data-set
I have written this code in JavaScript and works perfectly fine when I include
I have written this code in javascript however I have to make it work
Client + Server are both written in Javascript. I don't have a master game
I have written something like this in PHP <script type=text/javascript src=jquery.js></script></script> <script type=text/javascript> function
I have written the following Javascript but get the error 'Invalid JSON primitive: strSeason'.
I have a comment system written in PHP and JavaScript but each time I
I have written a javascript function that uses setInterval to manipulate a string every
I have written the following Javascript code : var outerFrame = document.getElementById(myframe); var outerDoc

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.