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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:06:03+00:00 2026-05-16T01:06:03+00:00

$.get(/student/Studentnumber.php, $(myform).serialize(), function(data){ alert(data); if(data.substring(0,7) == ‘STDERR’){ //$(#MYSPAN).text(data.substring(8)); } else { //$(#MYSPAN).text(data); } }

  • 0
$.get("/student/Studentnumber.php", $("myform").serialize(),
    function(data){
            alert(data);
            if(data.substring(0,7) == 'STDERR'){
                //$("#MYSPAN").text(data.substring(8));
        } else {
                //$("#MYSPAN").text(data);
        }
    }
);

In the Above Script I have The PHP response coming from the “Studentnumber.php” .The “Data” field contains the Contains the “Student NAME” if the correct number is entered .if a wrong number is entered it displays the “STDERR:SNO NOT VALID “.Now Here I want the respone only “SNO not VALID ” when a wrong number is entered .I want to over come the “STDERR:”

  • 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-16T01:06:04+00:00Added an answer on May 16, 2026 at 1:06 am

    You’re close.

    The index of the .substring() calls is off by 1.

    Try it out: http://jsfiddle.net/2GcS3/

    if(data.substring(0,6) == 'STDERR'){
        $("#MYSPAN").text(data.substring(7));
    } else {
        $("#MYSPAN").text(data);
    }​
    

    Update: This answer will still work, if you use $.trim() to get rid of the extra white space.

    data = $.trim(data);
    

    Otherwise, use the answer below.


    EDIT: From your comment, there is a space at the beginning of the STDERR. In that case, you need to go back to the numbers you had, and add that space to the STDERR string for comparison.

    Try it out: http://jsfiddle.net/2GcS3/1

    if(data.substring(0,7) == ' STDERR'){
        $("#MYSPAN").text(data.substring(8));
    } else {
        $("#MYSPAN").text(data);
    }​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

// inside $(document).ready function... var name = ''; function test() { $.post('/student/get-info', function(data) {
How do I get to make this sqsl query work: SELECT student.LASTNAME, student.FIRSTNAME, student.IDNO,
I have an object allStudents = Dictionary<ClassRoom, List<Student>>() In Linq how would I get
//Get width and resize another element $(document).ready(function() { function ResizeSearch(GridID, SearchID) { var eleWidth
//get the lat and loni throgh the loaddata function.java.util.ConcurrentModificationException at java.util.AbstractList$SimpleListIterator.next(AbstractList.java:64) How to resolve
I'm trying to get the rank of a certain student out of a class
I'm a PhD student looking at software watermarking techniques and I always get asked
I have two classes Teacher and Student . I am trying to get teacher
I have class Student { public List<Degree> Degrees {get;set;} } class Degree { public
Suppose I want to get student summaries from a two tables: student, grade: CREATE

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.