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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:59:20+00:00 2026-05-23T03:59:20+00:00

I was wondering if I can return an error callback back to my jquery

  • 0

I was wondering if I can return an error callback back to my jquery from my php page that I created, which will then display an alert based upon the actions that happen in my php page. I tried creating a header with a 404 error but that didn’t seem to work.

Sample JQuery Code:

$(document).ready(function()
    {
        var messageid= '12233122abdbc';
        var url = 'https://mail.google.com/mail/u/0/#all/' + messageid;
        var encodedurl = encodeURIComponent(url);
        var emailSubject = 'Testing123';
        var fromName = 'email@emailtest.com';

        var dataValues = "subject=" + emailSubject + "&url=" + encodedurl + "&from=" + fromName + "&messageID=" + messageid;
        $('#myForm').submit(function(){
            $.ajax({
                type: 'GET',
                data: dataValues,
                url: 'http://somepage.php',
                success: function(){
                     alert('It Was Sent')
                }
                error: function() {
                    alert('ERROR - MessageID Duplicate')
                }
            });
            return false;
        });
    });

Sample PHP Code aka somepage.php:

<?php
include_once('test1.php');
include_once('test2.php');


if(isset($_GET['subject']))
{
   $subject=$_GET['subject'];
}
else
{
   $subject="";
}

if(isset($_GET['url']))
{
   $url=$_GET['url'];
}
else
{
   $url="";
}
if(isset($_GET['from']))
{
    $from=$_GET['from'];
}
else
{
    $from="";
}

if(isset($_GET['messageID']))
{
    $messageID = $_GET['messageID'];
}
else
{
    $messageID="";
}



    $stoqbq = new test2($from, $messageID);
    $msgID = new stoqbq->getMessageID();
    if($msgID = $messageID)
    {
        header("HTTP/1.0 404 Not Found");
        exit;
    }
    else
    {
        $userID = $stoqbq->getUser();
        $stoqb = new test1($subject,$url,$messageID,$userID);
        $stoqb->sendtoquickbase();
    }

     ?>

-EDIT-

If you get the invalid label message when using json this is what I did to fix this problem:

Server Side PHP Code Part-

if($msgID == $messageID)
{
    $response["success"] = "Error: Message Already In Quickbase";
    echo $_GET['callback'].'('.json_encode($response).')';
}
else
{
    $userID = $stoqbq->getUser();
    $stoqb = new SendToQuickbase($subject,$url,$messageID,$userID);
    $stoqb->sendtoquickbase();
    $response["success"] = "Success: Sent To Quickbase";
    echo $_GET['callback'].'('.json_encode($response).')';
}

Client Side JQuery Part-

$('#myForm').submit(function(){
            $.ajax({
                type: 'GET',
                data: dataValues,
                cache: false,
                contentType: "application/json",
                dataType: "json",
                url: "http://somepage.php?&callback=?",
                success: function(response){
                    alert(response.success);
                }
            });
            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-23T03:59:20+00:00Added an answer on May 23, 2026 at 3:59 am

    You can a return a JSON response from your PHP with a success boolean.

    if($msgID = $messageID)
    {
        echo json_encode(array('success' => false));
    }
    else
    {
        $userID = $stoqbq->getUser();
        $stoqb = new test1($subject,$url,$messageID,$userID);
        $stoqb->sendtoquickbase();
        echo json_encode(array('success' => true));
    }
    

    and in your Javascript:

     $.ajax({
                type: 'GET',
                dataType: 'json',
                data: dataValues,
                url: 'http://somepage.php',
                success: function(response){
                     if(response.success) {
                       alert('Success');
                     }
                     else {
                       alert('Failure');
                     }
                }
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

just wondering is there any way that I can return one value from my
I'm wondering if I can return an object from json_encode() to JQuery. If I
I was wondering how can I validate a single checkbox using PHP and MySQL.
I was wondering how can I programmatically copy all the discussion items from one
I'm new to JQuery and was wondering how can I have Changes saved! displayed
I am wondering I can get some help at debugging or spotting the error
I am wondering why I can't compile an example from book. I simplify the
I was wondering if anyone can shed a light on the error I get
I'm testing an Ajax/jQuery-loaded PHP module and I was wondering if there's a simple
Value={TemplateBinding HeaderColor}I've created my own control, and I'm wondering if I can bind a

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.