Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
am facing retrieving the value from query string, how to solve this?

url :

http://localhost:2369/Forms/Users/EDITUsers.htm?UserID=1


here am using code:
JavaScript
var App = angular.module('EditApp', []);

App.controller("EditController",  function ($scope, $http, $location) {
       var QueryStrValue = $location.search();
       alert("Querystr value: " + QueryStrValue.UserID);
});
Posted
Comments
[no name] 16-Nov-15 6:39am    
you can try
alert("Querystr value: " +$location.search()['UserID']);
ram_raj 16-Nov-15 7:32am    
thanks PANKAJMAURYA, same result undefined,
George Jonsson 16-Nov-15 22:30pm    
Is QueryStrValue also undefined or only QueryStrValue.UserID?
ram_raj 17-Nov-15 0:08am    
QueryStrValue.UserID result - QueryStrValue: Undefined , QueryStrValue result - QueryStrValue: [object Object]

1 solution

Some trouble shooting help.

QueryStrValue: [object Object] means that you get a result, but UserID is not a member of the result structure as proven by QueryStrValue.UserID = Undefined.

What is the expected result? A JSON string or something else.
Try to print it out with .toString() or investigate the contents of the result.

What is the result if you put the URL 'http://localhost:2369/Forms/Users/EDITUsers.htm?UserID=1' directly in the browser?
 
Share this answer
 
Comments
ram_raj 18-Nov-15 6:41am    
Hi,
Am passing userID as query string (UserID=1) from page A to Page B, then display the alert message in Page B using JSON format,
George Jonsson 18-Nov-15 12:24pm    
Still, what is the expected JSON structure?

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900