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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:03:38+00:00 2026-06-01T16:03:38+00:00

I have an Ajax call to the server that only works when I pass

  • 0

I have an Ajax call to the server that only works when I pass an alert(); to it. Cannot figure out what is wrong. Can anyone help?

OBJECTIVE

  1. If “Update” button clicked in PrettyPhoto iFrame – then (a) call server to run PHP script that updates backend database, (b) close PrettyPhoto window, and (c) refresh page
  2. If “Don’t Update” button clicked in PrettyPhoto iFrame – just (a) close PrettyPhoto window, and (b) refresh page

This Does Not Work (ie., Ajax call to server does not get made):

jQuery.support.cors = true; // needed for ajax to work in certain older browsers and versions

$('input[name="status"]').on("change", function() {

    if ($('input:radio[name="status"]:checked').val() == 'Y') {

        $.ajax({
            url: 'http://mydomain.com/dir/myPHPscript.php?param=' + $('#param').val() + '&id=' + ( $('#id').val() * 1 ) + '&mode=' + $('#mode').val()
        });

    }

    window.parent.closePP();

    window.top.location.href = $('#redirect').val();    // reloads page

});

This Works! (ie., Ajax call to server gets made when I have the alert() present):

jQuery.support.cors = true; // needed for ajax to work in certain older browsers and versions

$('input[name="status"]').on("change", function() {

    if ($('input:radio[name="status"]:checked').val() == 'Y') {

        $.ajax({
            url: 'http://mydomain.com/dir/myPHPscript.php?param=' + $('#param').val() + '&id=' + ( $('#id').val() * 1 ) + '&mode=' + $('#mode').val()
        });

        alert('this makes it work');

    }

    window.parent.closePP();

    window.top.location.href = $('#redirect').val();    // reloads page

});

Thanks.

Made numerous revisions based on answers — still can’t get it to work. Here’s latest:

jQuery.support.cors = true; // needed for ajax to work in certain older browsers and versions

$('input[name="status"]').on("change", function() {

if ($('input:radio[name="status"]:checked').val() == 'Y') {

    $.ajax({
        url: 'http://mydomain.com/dir/myPHPscript.php?param=' + $('#param').val() + '&id=' + ( $('#id').val() * 1 ) + '&mode=' + $('#mode').val(),
        success: functions(data) {var $doNothing = data;}
    });

}

window.parent.closePP();
window.top.location.href = $('#redirect').val();    // reloads page

});
  • 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-01T16:03:39+00:00Added an answer on June 1, 2026 at 4:03 pm

    You need to do the rest in the Ajax callback

    See jquery ajax

    $('input[name="status"]').on("change", function() {
        if ($('input:radio[name="status"]:checked').val() == 'Y') {
            $.ajax({
                url: 'http://mydomain.com/dir/myPHPscript.php?param=' + $('#param').val() + '&id=' + ( $('#id').val() * 1 ) + '&mode=' + $('#mode').val()
            },
            success:function() {
              window.parent.closePP();
              window.top.location.href = $('#redirect').val();    // reloads page
            });
         }
         else {
              window.parent.closePP();
         }
     });
    

    You can also just get the data:

    $('input[name="status"]').on("change", function() {
        if ($('input:radio[name="status"]:checked').val() == 'Y') {
            $.get('http://mydomain.com/dir/myPHPscript.php?param=' + $('#param').val() + '&id=' + ( $('#id').val() * 1 ) + '&mode=' + $('#mode').val(), 
             function() {
              window.parent.closePP();
              window.top.location.href = $('#redirect').val();    // reloads page
            });
         }
         else {
              window.parent.closePP();
         }
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an AJAX call getting info out of the Github API. It is
I have an ajax call that fires multiple times but is called once. function
I have a ajax call on my onkeyup event, that checks if the given
I have a jQuery ajax call that returns html of a table. Now I
I have a jQuery AJAX call that I will need to do multiple times
I have a problem with IE7 regarding an ajax call that is made by
In my javacript function I call this ajax. It works fine but only when
I need a jquery autocomplete that only does one call to the server then
I have an ajax call in my code. What I want to achieve with
i have an ajax call $.ajax({ url: '<%=Url.Action(SaveDetails,Survey) %>', dataType: 'JSON', cache: false, data:

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.