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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:45:40+00:00 2026-05-23T02:45:40+00:00

Not sure why the following doesn’t work. I hope somebody can shed some light.

  • 0

Not sure why the following doesn’t work. I hope somebody can shed some light.

I have a global parameter reresenting a certain id of an item in a database. Now in order to check if the db should be updated or a new entry should be made for the item, I check before making the ajax call if the variable is set. If the variable is set, I know I have to update the db, if its not set I know I have to insert into the db. Then on the server side I return a newly generated id in case of an insert or else just the old id in case of an update. I use the jQuery form and validate plugins by the way (hence the function call ajaxSubmit()). However, the assignment in the success function of submitHandler doesn’t seem to work (I have checked that data.poiId returns a suspected result).

$(document).ready(function() {

    // Function which examines window.location.href and extracts a numerical id if there is one specified in the query
    var id = getParameter('poiId')

   ...

   },
   submitHandler : function(form) {
       var str = 'submitPOI.php';
       if (id.length > 0) str += '?poiId=' + id;

       $(form).ajaxSubmit({
           url : str,
           type : 'POST',
           dataType : 'json',
           success : function(data) {
               id = data.poiId     // Update POI id with response from server
           } 
       });
   }

   ...
});
  • 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-23T02:45:41+00:00Added an answer on May 23, 2026 at 2:45 am

    Seems to me that your id variable is not global as it is declared in the $(document).ready() function. Move it outside the function and check if it works.

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

Sidebar

Related Questions

I have the following and am not sure why it doesn't work. It outputs
I'm not sure why the following doesn't work. It doesn't enter the geocoder.geocode segment
The following doesn't work and not sure why. I should get the ID passed
I'm not sure why the following doesn't work. StructureMap tells me there is no
I'm not sure why the following subquery doesn't work in SQL Server, when I
I have the following code; I want to make sure that submit does not
I'm not sure if the following code can cause redundant calculations, or is it
I'm not sure what's wrong with the following setup. I have a View that
i'm not sure how to solve the following problem: i have a triangle with
I have the following to solve and I'm not sure how to approach this:

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.