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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:21:46+00:00 2026-05-23T21:21:46+00:00

What is wrong with this code? I am using jQuery. function setPreviewUrl() { $post_title

  • 0

What is wrong with this code? I am using jQuery.

function setPreviewUrl() {
        $post_title = $("#post_title").val();
        $post_content = $("#post_content").val();
        $.get('ajax/base64encode.php?name='+post_title, function(data1) {
            var $postTitle  =   null;
            $postTitle  =   data1;
        });
        $.get('ajax/base64encode.php?name='+post_content, function(data2) {
            var $postCont   =   null;
            $postCont   =   data2;
        });
        var $urlExten   =   null;
        $urlExten   =   '?post_title='+postTitle+'&post_cont='+postCont;
        $("a[href*='#change']").attr('href', '<?php echo $site_url; ?>admin/ajax/preview.php'+urlExten);
        $("#preview_frame").prop("href", '<?php echo $site_url; ?>admin/ajax/preview.php'+urlExten);
    }
  • 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-23T21:21:47+00:00Added an answer on May 23, 2026 at 9:21 pm

    It seems like you’re messing up with asynchronous code:

    function setPreviewUrl() {
            var $post_title = null; 
            $post_title = $("#post_title").val();
            var $post_content = null; 
            $post_content = $("#post_content").val();
            $.get('ajax/base64encode.php?name='+post_title, function(data1) {
                var $postTitle  =   null;
                $postTitle  =   data1;
            });
            $.get('ajax/base64encode.php?name='+post_content, function(data2) {
                var $postCont   =   null;
                $postCont   =   data2;
            });
            // Those functions above will execute when the get is done, in the
            // meantime the code below is executed, so the variables have not been
            // set yet.
            // Also, the variables are only declared inside the get function so they
            // are not accessible due to their scope.
            var $urlExten   =   null;
            $urlExten   =   '?post_title='+postTitle+'&post_cont='+postCont;
            $("a[href*='#change']").attr('href', '<?php echo $site_url; ?>admin/ajax/preview.php'+urlExten);
            $("#preview_frame").prop("href", '<?php echo $site_url; ?>admin/ajax/preview.php'+urlExten);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this $.ajax (using jquery) code, it originally was the $.get that is
I am using this code from http://www.joe-stevens.com/2010/01/04/using-jquery-to-make-ajax-calls-to-an-asmx-web-service-using-asp-net/ function callWebService(address) { var result; $(#result).addClass(loading); $.ajax({
I'm using Ajax file upload function with its javascript / jQuery library . When
I'm using current jQuery plugin (address) and I have this code (I'm using SEO
I'm trying to create a list links using jquery. I'm using this code to
I can run this code in Android app (using PhoneGap adn jQuery Mobile) but
I tried doing selecting multiple rows using jquery but this code look like cranky.
I am using a jquery click function: Button code <input type=button id=myButtton> Jquery code
I'm using this jQuery function to jumping on input styled components of the form:
This is my below code to retrieve the checkbox values using jquery . <div

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.