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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:40:10+00:00 2026-05-15T08:40:10+00:00

I am trying to save an array of records into a mysql database but

  • 0

I am trying to save an array of records into a mysql database but I always get the abort message in firebug except for the last save. How do I save the records using a loop for XMLHttpRequest? Here is my code:

function savingContent()
{
   if (window.XMLHttpRequest)
   {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();

   }
   else
   {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   var rowindex = 0;

   for (x in globalObj.AddedRows)
   {
      var rowData = "?q=" + globalObj.AddedRows[rowindex];

      xmlhttp.open("POST", "insertRowData.php"+rowData, true);
      xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
      xmlhttp.setRequestHeader("Content-Length",rowData.length); 
      xmlhttp.send(null);
      rowindex += 1;
}
  • 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-05-15T08:40:10+00:00Added an answer on May 15, 2026 at 8:40 am

    There are quite a few problems with this code. Here are just the first ones I found:

    1. The for (x in object) syntax should only be used when you want to iterate over all fields in an object. In this case you want to iterate over an array, so you should do it like this:

      for (var rowindex = 0; rowindex < globalObj.AddedRows.length; rowindex++) {
      }
      
    2. When doing an HTTP POST, you shouldn’t put the data you want to change into the URL. Put it in the body of the request – as the argument to xmlhttp.send(). You’re actually explicitly passing a content length – that length is supposed to be the length of the data you pass to xmlhttp.send() – so by passing NULL this is almost certainly your main error.

    3. Rather than using Firebug, it’d be better to use xmlhttp.onreadystatechange to figure out which of your requests are succeeding or failing. Don’t assume that once you have it debugged the first time, it will always succeed from then on. Handle errors.

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

Sidebar

Related Questions

I'm trying to save received data into file: #data Array[byte] fl = open(file_name, 'wb')
I'm trying to save a jquery selector's result into an array so I can
I'm trying to save some values from a form in CakePHP into a MySQL
I'm trying to save an array to Core Data. I've been reviewing the following
I am trying to save an array of images to the documents folder. I
I'm trying to save a binary file stored in a SQL database with a
So I am trying to save arrays into an NSDictionary on the fly. Let
I am trying to save some images from Flash to Php by sending a
I'm starting with jQuery and trying to save myself lots of code in a
Hey all, weird question. My company has an application from another company that records

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.