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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:53:31+00:00 2026-06-09T08:53:31+00:00

I got this Jquery code : $.ajax({ url: ?module=gestionApplication&action=getTests&scenario=+encodeURI(scenario)+&application=+$application, dataType:’json’, success: function( data )

  • 0

I got this Jquery code :

$.ajax({
    url: "?module=gestionApplication&action=getTests&scenario="+encodeURI(scenario)+"&application="+$application,
    dataType:'json',
    success: function( data ) {
        $.each(data, function(i, item) {
            $("#tests tbody").append($tr+"<td title='"+item.DESCRIPTION+"'>"+item.ID+"</td>" +
            "<td>"+
                "Header : "+item.HEADER + '<br/>' +
                "Méthode : "+item.METHODE +  '<br/>' +
                "PostBody : "+item.POSTBODY +  '<br/>' +
                "URL : "+item.URL +  '<br/>' +
                "ParseReponse : "+item.PARSEREPONSE +  '<br/>' +
            "</td>" +

So i got a JSON response from my server, but not all fields are full. Sometimes item.HEADER or item.METHODE can not be defined, so I get “undefined” text in my table. Problem is, I’m French and I would like different text and not this ‘undefined’.

So how can I test if the variable is defined or not? Or even better, is it possible to change this ‘undefined’ text to different text in case the variable is not defined?

  • 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-09T08:53:33+00:00Added an answer on June 9, 2026 at 8:53 am

    You can do a quick conditional / logical-OR check within your concat:

    "Header : " + (item.HEADER || '') + '<br/>' +
    

    so now, if item.HEADER is undefined we will encounter the empty string instead. Of course you could also use a more expressive string like "empty" or whatnot.

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

Sidebar

Related Questions

I'm new to Jquery. I have a code like this : $.ajax({ url: ${createLink(controller
I got this code today that works for jQuery v7. The problem is that
i got a jquery code from this link (end of page): How to scroll
I have got this code: function init(){ if (typeof window.jQuery !== 'function') { var
I've got this piece of code in my jquery validation script: resetForm: function() {
I'm upgrading an app from prototype.js to jquery. I've got this code (prototype.js): var
I am using CakePHP 1.26 and CDN JQuery in this URL: http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js In a
I've got some code that calls via jQuery and Ajax an asp page to
Hey guys, I've got this jQuery code which works in Chrome and Safari but
I've got this textBox which triggers off an ajax request using jQuery: <asp:TextBox ID=postcodeTextBox

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.