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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:40:11+00:00 2026-05-26T08:40:11+00:00

As you can see I am retrieving JSON data from my ajax call but

  • 0

As you can see I am retrieving JSON data from my ajax call but if the database can’t find anything it returns the print value of null.

e.g. print "null";

as you can see with case 1 I have asked it if it can not find obj.id then show this.

However as there is NO JSON being returned it should be if(data == "null") however it seems to work when I do that either.

I basically need it to notice that it could not find it, and to stop the script.

here is my jquery code.

    function fetch(e,formstring)
{

    $.ajax({
      type: 'POST',
      url: 'system/classes/core.php',
      data: formstring,
      dataType: 'json',
      contentType: "application/x-www-form-urlencoded;charset=utf-8",
      success: function(data){
          $.each(data, function(i, obj) {

               switch (e) { 
                 case 1:
                 if(!obj.id)
                 {
                    shownotify(1,"Sorry An error was found. Check Username / Password.");
                    alert("error");
                    shownotify(2,"");
                    return false;
                 }

                  $.each(obj, function(key, val) {
                     alert(key+" - "+val);
                  });


                 break;
                 case 2:
                 $.each(obj, function(key, val) {
                    if(val != 0)
                    {
                        $("#betataken").html("<span style='color:red'><b>"+betacode+"</b> - NOT VALID");
                    }
                    else
                    {
                        $("#betataken").html('<img src="theme/sysimages/tick.png"/><span style=" color: white;"><b>'+betacode+'</b> is valid</span');
                    }
                 });
                 break;
                 case 3:
                 $.each(obj, function(key, val) {
                     if(val != 0)
                     {
                        $("#usernametaken").html("<span style='color:red'><b>"+username+"</b> - is taken");  
                     }
                     else
                     {
                        $("#usernametaken").html('<img src="theme/sysimages/tick.png"/><span style=" color: white;"><b>'+username+'</b> is valid</span');
                     }
                     unamecheck = val;
                  });
                 break; 
                 case 4:
                 //LoginSript

                    $('#rightheader').html(obj.code);
                 break;
                 case 5:
                 //WelcomePage/Signup
                    $('#window').html(obj.code);
                 break;
               }
         });
      },
      error: function(data){
      $.each(data,function(i,myinfo){
            alert(i);       
          });
      },
      complete: function(){
        shownotify(2,"");  
      }
    });
    return false;
}
  • 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-26T08:40:12+00:00Added an answer on May 26, 2026 at 8:40 am

    You could return null as json ($return['result'] = 'null'; in the php-file).
    In your js:

    [...]
    dataType: 'json',
          contentType: "application/x-www-form-urlencoded;charset=utf-8",
          success: function(data){
          result = jQuery.parseJSON(data);
          if (result['result'] != 'null') {
              $.each(data, function(i, obj) {
                  [...]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can see that Collections.unmodifiableSet returns an unmodifiable view of the given set but
I'm retrieving the elevation data from the Google Maps API by AJAX. I'm getting
I'm working on an application that opens a database connection and retrieving data from
This is an Easy Q, but great help: Under title Retrieving data from threads
I can see that GD library is for images. But I can't see differences
I can see some potential difficulties with this concept but the idea is: I
I'm retrieving some data from Twitter using the code below Dim FilterData = follow=13,15
When retrieving data from MySQL, the PHP array output has both numeric and name
I'm having trouble retrieving JSONP data from one of my sites. On Site A
I know we can see the USER WALL by retrieving a token and all...

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.