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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:42:50+00:00 2026-05-23T06:42:50+00:00

I need to pass the response from ajax call to a jquery template.The response

  • 0

I need to pass the response from ajax call to a jquery template.The response json is not malformed.I have checked this by using alert statements in the ajax fn.When the response is passed to the template,it does not get recognized.For example,when I use ${field1} in template,nothing gets displayed in the browser.No error messages are displayed at the browser.Can someone help me fix this issue?

Json response from server:

    { 
        "field1": 23432434, 
        "field2": "sometext",
    }

Ajax fn:

    function getinfo(uri)
    {
        jQuery.ajax({
        url:    'http://{{request.META.SERVER_NAME}}'+uri,
        success: function(info) {
                  return info;
              },
        async:   false,
        dataType: 'jsonp'
        });
     }

Template:

    <script id="infoTemplate" type="text/x-jQuery-tmpl">
            <div>${field1}</div>
   </script>

Code to Bind JSON to template:

<script id="Template1" type="text/x-jQuery-tmpl">      
      {{tmpl(getinfo(uri)) "#infoTemplate"}} 
</script>

Note: I can’t use the following method to bind JSON with template.That’s a long story.

function getinfo(uri)
{
    $.getJSON('http://{{request.META.SERVER_NAME}}'+uri, function(data) {
         $("#infoTemplate").tmpl(data).appendTo("#somedivid");
   });
}
  • 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-23T06:42:51+00:00Added an answer on May 23, 2026 at 6:42 am

    That’s not how callbacks work. You’re returning info to the callback function, and not to getinfo.

    You either have to do something like you proposed after, or keep the result from the ajax call in a global var and call the tmpl function after while, to be sure that you have already got the answer from the ajax call. The first way is the way to go.

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

Sidebar

Related Questions

I have this star rating, I implemented from jQuery and I need to save
I am getting a JSON response from a web service but it is not
How do I pass a query string from a response, meantime the relative template
I am making ajax call(ASP.NET 3.5) from dropdown change handler and trying to pass
Say I submit a form via Ajax and need a response from the server:
I need to pass configuration settings to an AddIn created using the Managed AddIn
I need to pass an url from asp.net load_page to flowplayer javascript function here:
We have a restlet server and client. We need to pass the error status
I need to pass (via string content of a HTTP request/response body) name value
I'm uwsing MVC and jqgrid and I need to pass a value from dropdownlist

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.