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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:39:59+00:00 2026-06-07T05:39:59+00:00

I have a text box that I am the user enters a Supplier Name

  • 0

I have a text box that I am the user enters a Supplier Name into. On the blur I want to check a webservice to see if the Supplier exists, and if it does I would like to return the Supplier ID from the webservice and use it to populate another text box.

The webservice is working fine because I am using it fine in other places (with similar code to do autocomplete) It returns the data in JSON and looks like this:

<?xml version="1.0" encoding="UTF-8"?>
-<ArrayOfSuppliers xmlns="http://tempuri.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
  -<Suppliers> 
       <SupplierID>1</SupplierID> 
       <SupplierName>Supplier 1</SupplierName> 
   </Suppliers> 
 </ArrayOfSuppliers>

This following code is a mess, and will not work as it is. I hope that it helps explain what I am trying to do, and also so you can help me to understand what I am doing wrong and how the data is returned and usable.

As a starting point I am getting an error that ‘response’ is undefined. I can see why, but I don’t understand enough to know what I need to do to fix it.

   $(document).ready(function () {
    $("[id$=txtSupplier]").blur(function () {

        $.ajax({
             type: "POST",
             url: "http://localhost:52350/FabRouting/Webservice/SupplierList.asmx/GetSuppliers",
             data: "{ 'SupplierSearch': '" + $("[id$=txtSupplier]").val() + "' }",
             contentType: "application/json; charset=utf-8",
             dataType: "json",
             dataFilter: function (data) { return data; },
             success: function (data) {
                response($.map(data.d, function (item) {
                   return {
                   value: item.SupplierName,
                   id: item.SupplierID
                 }
                 }))
                 },
             error: function(e){
                 $("[id$=lblSupplier]").html("Unavailable");              
             }
         });
        }
        );
    });

After I get this working I still need to know how to take what is returned and set a text box, but I can probably work my way through that if I can get this code to somewhat function.

Edit

I have some autocomplete working with this code:

$(document).ready(function () {
$(".cRejectedOnSDRR").autocomplete({
    source: function (request, response) {
        $.ajax({
            url: "http://localhost:52350/FabRouting/Webservice/ReportList.asmx/GetReports",
            data: "{ 'ReportNumberSearch': '" + request.term + "' }",
            dataType: "json",
            type: "POST",
            contentType: "application/json; charset=utf-8",
            dataFilter: function (data) { return data; },
            success: function (data) {
                response($.map(data.d, function (item) {
                    return {
                        value: item.ReportNumber,
                        id: item.SDRRID
                    }
                }))
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(textStatus);
            }
        });
    },
    minLength: 1,
    select: function (event, ui) {
        $("[id$=lblRejectedOnSDRRID]").html(ui.item.id);
    },
});

});

And was trying to use that as a basis to do what I mentioned at the top with the blur. I don’t understand enough how to simply get and use the data returned from a webservice so I was trying to reverse engineer the autocomplete code to help myself understand it.

  • 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-07T05:40:00+00:00Added an answer on June 7, 2026 at 5:40 am

    Well I finally figured it out. I was pretty sure I was on the wrong path but I didn’t know what I was doing wrong or how to access the data returned from the web service. Darin was helpful it getting me to fight some more with the code and not give up. I don’t think he fully understood what I wanted to do, but did understand that I was trying to use code that I didn’t understand 🙂 I did use his stringify suggestion in my final result, but it was working without it as well… he was just mentioning this as a better option than the code I was using for that purpose I am assuming.

    I finally started to figure out the correct syntax – aka: data.d.SupplierID but even though that seemed to be working for other people on the web it would still not return what I was looking for. I finally came across someone that was using the index – aka: data.d[0].SupplierID and it finally started to work for me. I was wondering about the index for a while but didn’t understand how to handle it.

    Here is the final working code:

        $(document).ready(function () {
        $("[id$=txtSupplier]").blur(function () {
    
            $.ajax({
                type: "POST",
                url: "http://localhost:52350/FabRouting/Webservice/SupplierList.asmx/CheckSupplier",
                data: JSON.stringify({ SupplierSearch: $("[id$=txtSupplier]").val() }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(data){
                    if (data.d.length == 0) {
                        $("[id$=lblSupplierID]").html("0");
                    }
                    else {
                        $("[id$=lblSupplierID]").html(data.d[0].SupplierID);
                    }
                },
                 error: function(e){
                     $("[id$=lblSupplierID]").html("0");
                 }
             });
            }
            );
        });
    

    I added the if statement to check for nulls because it was not causing an error when no results were found so I couldn’t handle it in the error function. I am assuming this is by design because a SQL query returning null is not necessarily an error, just something I need to deal with. If anyone has a better (or correct) way to handle this please let me know.

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

Sidebar

Related Questions

I have an Email Id text box. My requirement is that an user enters
I have a text box that will allow the user to enter multiple authors
I have a program which has a text box that the user can edit.
I have received requirements that ask to normalize text box content when the user
I have an activity that has an EditText. After a user enters their text,
I have WPF application in which user enters some text in rich text box(rtb),
I have a text box I need to validate that.. I mean user can
I have a text box that contains lines of data similar to this: sheep
I have a text box that is going to be populated with a comma
I have a text box that accepts integers, and I need it to run

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.