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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:28:45+00:00 2026-06-04T17:28:45+00:00

In my django view ,I am using simplejson to convert some search results to

  • 0

In my django view ,I am using simplejson to convert some search results to json

vals = [('supposed to be a toaster.', 8),('we can do more than one thing.',14),("we could make a bicycle.",51)]

result={'results':vals}

serialized = simplejson.dumps(result)

serialized=>

{"msg": "success!.",  "results": [["supposed to be a toaster.", 8], ["we can do more than one thing.", 14], [" we could make a bicycle.", 51]]}

I can send this serialized data to javascript function by

return HttpResponse(serialized, mimetype="application/json")

In my javascript function(using jquery),I can retrieve the data as

var data = $.parseJSON(res.responseText);
var results = data['results']

I would like to show the results in the following format

8  -- supposed to be a toaster. 
14 -- we can do more than one thing
51 -- we could make a bicycle

How can I do this in javascript? The javascript variable results contain s

supposed to be a toaster.,8,we can do more than one thing.,14,we could make a bicycle.,51,

Will I have to use regex to separate the items?or is there a better solution? What makes use of regex difficult is that,the
strings may sometimes contain numbers .

Edit

Thanks to the replies by Priyank and alexey28 ,I tried

for(var item in results) {
    var time = results[item][1];
    console.log('time='+time);
    var resStr =results[item][0];
    console.log('resStr='+resStr);
    formatedResult += time+ " --- " + resStr+'<br>';
}
$('#showresults').html(formatedResult);
  • 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-04T17:28:46+00:00Added an answer on June 4, 2026 at 5:28 pm

    Variable data will contains array, so you can:

    var formatedResult = "";
    for(var i = 0; i < data.length; i++) {
        var item = data[i];
        formatedResult += item[1] + " --- " + item[0];
    }
    // Set html for you <div id="resultOutput"></div>:
    jQuery("div#resultOutput").html(formatedResult);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using django and have a page of search results that I want to
I tried to submit this form using ajax ,sothat a django view can extract
I have 2 forms in my Django view. How can I do a check
I am sending an AJAX request to a Django view that can potentially take
I'm trying to return a JSON response from a Django view call via an
I'm trying to write a simple search server, using Django with AJAX. The server
Does anyone know how you can use Django's templatetags in view? I want to
I'm trying to pass keyword arguments to a Django view using a dictionary, but
I want to start processing some files from a django view and I want
I am using Django generic View but when i type /book/edit/9/ Then it says

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.