Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript VB.NET DevExpress , +
I have created an "usercontrol" which will accept the zip code and display state and city(returning in json format).
So I have written keyup function for zipcode textbox in javacript.
In javascript side, I want to call the webservice.
Here is my code written in the ascx page:
function OnKeyUP(s, e) {
        var len = txtZip.GetText();
            var newstring = len.replace(/[_-]/g, '');
            if (newstring.length == 5) {              
 
                $.ajax(
                    {
                        type: "POST",
                        url: '~/CityStateZipCodes.asmx/GetCityStateZipCodes',
                        data: "{'zip':'77853'}",
                        async: false,
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (msg) {
                            alert(msg);                           
                        },
                        error: function () {
                            alert('error');
                        }
                    });
                }
             }
But I am unable to call the webservice, can someone please help me out how to call, or give an example.
Posted 11-Feb-13 4:49am
v3
Comments
Irbaz Haider Hashmi at 11-Feb-13 10:14am
   
When a control is render on page the id of the html elements get changed. More information will be required in order to understand this. What error you are getting? or your javascript function is not executed at all.
 
Try by adding debugger; in javascript.
Try moving your code on the page rather than writing it on control.
rkuttarakabat at 11-Feb-13 10:32am
   
The java script is executed, but its not able to call the web service, i am getting an alert as error as mentioned in the code. I have to write the code in user control as i want to use this usercontrol in many a places.
Irbaz Haider Hashmi at 11-Feb-13 10:50am
   
try entering the complete URL of the webservice. what error are you getting? 403,404?
rkuttarakabat at 11-Feb-13 10:58am
   
its not at all calling the the web service, if possible can u give me an example for it.
rkuttarakabat at 12-Feb-13 4:32am
   
i am getting an error as "object XMLHttpRequest"
rkuttarakabat at 12-Feb-13 10:15am
   
i am getting HTTP/1.1 500 Internal Server Error

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
rkuttarakabat at 12-Feb-13 1:39am
   
this is working in normal pages, but i want in a usercontrol, and its not helping me to call the webservice.
   
Check this: http://stackoverflow.com/questions/579024/calling-an-ascx-page-method-using-jquery

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 11 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100