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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:47:25+00:00 2026-05-21T06:47:25+00:00

function getNewMessages(id) { clearJqGrid(); var lat; var lng; var jsonData; var geocoder = new

  • 0
function getNewMessages(id)
        {
            clearJqGrid();
            var lat;
            var lng;
            var jsonData;
            var geocoder = new google.maps.Geocoder();
            var miles = $('#milesAway').val();

            // find what the user is locating by
            if ($('#zipCode').is(':visible'))
            {
                var zipText = $('#zipCode').val();
                if (isValidUSZip(zipText))
                {
                    geocoder.geocode( { 'address': zipText}, function(results, status) {
                      if (status == google.maps.GeocoderStatus.OK) {
                         lat = results[0].geometry.location.lat();
                         lng = results[0].geometry.location.lng();
                         map.setCenter(results[0].geometry.location);
                      } else {
                        alert("Zip Code couldn't be located.");
                      }
                    });
                }
                else
                {
                    alert('Please enter a valid US zip code.');
                }
            }
            else if ($('#cityState').is(':visible'))
            {
                var address = $('#cityState').val();
                geocoder.geocode( { 'address': address}, function(results, status) {
                    if (status == google.maps.GeocoderStatus.OK) {
                        lat = results[0].geometry.location.lat();
                        lng = results[0].geometry.location.lng();
                        map.setCenter(results[0].geometry.location);
                    } else {
                    alert("City/State combination couldn't be found.");
                    }
                });
            }
            else
            {
                var latlng = map.getCenter();
                lat = latlng.lat();
                lng = latlng.lng();
                jsonData = 
                {
                    latitude: lat,
                    longitude: lng,
                    milesAway: miles
                }
            }

            $.ajax(
            {
                type: "POST",
                url: "<%= Url.Action("CalcLocation", "Home") %>",
                data: jsonData,
                success: function (result) {
                    var messages = result;
                    for(var i=0;i<messages.length;i++) 
                        jQuery("#responseMessages").jqGrid(
                                                            'addRowData',
                                                            i+1,
                                                            {distance:messages[i].distance,age:messages[i].age,message:messages[i].message}
                                                          );
                },
                error: function (error) {

                }
            });
        }

So it’s only making the AJAX call if it goes through the ‘else’ part of the if statement, not the others. Why?

  • 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-21T06:47:26+00:00Added an answer on May 21, 2026 at 6:47 am

    Milimetric actually got it right, I believe – you’re missing the semicolon in your jsonData object literal definition. That combined with JavaScript’s auto-semi-colon insertion and the way your braces {} are written to begin on a new line, is very likely the problem. Put in a semi-colon in there and it should work fine.

    In other C-like languages, putting the opening brace on a new line or on the same line is a personal preference but in JavaScript, it does make a difference and so I’d recommend you make a conscious effort to put opening braces on the same line.

    • http://encosia.com/2011/03/21/in-javascript-curly-brace-placement-matters-an-example/
    • http://robertnyman.com/2008/10/16/beware-of-javascript-semicolon-insertion/
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function initialize() { var myOptions = { center: new google.maps.LatLng(23.71181,90.407467), zoom: 8, mapTypeId: google.maps.MapTypeId.ROADMAP
function dowork() { $(.wrappedElement).removeClass(wrappedElement); $(.wrappedElementout).removeClass(wrappedElementout); var a=$(div#DepPart select option:selected).val(); $(div#TestPart select option[value^=a]).addClass(wrappedElement); $(div#TestPart select
function controllaFoto(target, username) { var _URL = window.URL || window.webkitURL; var img = new
function logsig() { var username = $(#username).val(); var password = $(#password).val(); var dataString =
function ajaxFunction2(){ var chooser2 = $('#chooser2').val(); $('#floatcontainertop').css(background,$('#chooser2').val()); } Could someone please tell me how
function main() { Hello(); } function Hello() { // How do you find out
function register_contact ($person = array()) { $nogood = false; foreach ($person as $val) {
function check(id){ var _id = document.getElementById(id); url = test.php?check=1&id= + _id; } i want
function countChars(elm) { if (elm.nodeType == 3) { // TEXT_NODE return elm.nodeValue.length; } var
function example(){ var quantity = http://www.example.com/index.php?brandid=b%123&quantity=20; quantity = quantity.replace(-what regular expression should i user-,

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.