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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:20:54+00:00 2026-05-27T07:20:54+00:00

given the following: where data is a string received as an AJAX value and

  • 0

given the following:
where data is a string received as an AJAX value and data has a value of ‘good’:

console.log data          # good
console.log typeof data   # string
console.log typeof 'data' # string

if data is 'good'
  console.log 'test' # NOTHING!!!

I don’t understand…

makes me want the good ol’ JavaScript back…

A more complete example after a suggestion:

The following does not work either…

  $('#profile_slug').keyup(()->
    if $(this).val() != original_slug
      value = encodeURIComponent $(this).val()
      console.log value
      $.get('/live_validate/slug?slug='+value, (data)->

        console.log data
        console.log typeof data
        console.log typeof 'data'

        `
        if (data == 'good') {
          console.log('test');
        }

       `

update 2

oddly enough:

console.dir data
console.dir 'good'

good
No Properties

good
No Properties

update 3

controller

  if @slug.nil?
    @message = "good"
  else
    @message = "bad"
  end

view

!= @message

coffeescript

new_data = data.replace /^\s+|\s+$/g, ""

result

same sh*t.

update 4 + answer

This code ended up being what I needed, at first it didn’t work quite well with everything else I had going on, but it is the final piece in the puzzle, allowing me to make sure there are no invisible spaces before or after the received string.

    $.get('/live_validate/slug?slug='+value, (data)->
        # console.log data

        stripped_data = data.replace /^\s+|\s+$/g, ""

        # console.log encodeURIComponent data
        # console.log (data.charCodeAt(i) for i in [0...data.length])       


        if stripped_data is 'good'
          $('#profile_slug').addClass('valid-field')
          $('#profile_slug').removeClass('invalid-field')
        else if stripped_data is 'bad'
          $('#profile_slug').addClass('invalid-field')
          $('#profile_slug').removeClass('valid-field')
  • 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-27T07:20:55+00:00Added an answer on May 27, 2026 at 7:20 am

    It ended up being an invisible character at the end of the ajax response string… thanks all!

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

Sidebar

Related Questions

Given the following connection string (for SQL Server CE 4.0) Data Source=|DataDirectory|IntegrationTests.sdf how do
Given the following: let f<'a,'b> = typeof<'a>.Name, typeof<'b>.Name //val f<'a,'b> : string * string
I have an odd linq subquery issue. Given the following data structure: Parents Children
Given the following schema / data / output how would I format a SQL
Given the following example data: Users +--------------------------------------------------+ | ID | First Name | Last
Given the following simple BST definition: data Tree x = Empty | Leaf x
How can you sort the following word by the given rule? Example data is
Hey guys, given a data set in plain text such as the following: ==Events==
// given following array: $data = array( 0=>array( data=>object1, col=>array( 0=>array( data=>object2, col=>array( 0=>array(
Given the following class.... namespace IMTool.Data { public partial class AllContracts { internal class

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.