How do I search results from jquery GET


I'm having a bit of a problem investigating the result from my get in my script. I got the following code to check if a user is still logged in:

$.get("nowhereGet", function(result){ if($(result).find('[id="loginInput"]')) { //HTML is in the response then we have been logged out and the user needs to go to window.location.href = "login"; } });

Now if the user is logged in Struts will return one html-page in result from my get. If the user has been logged out different page will be returned one with and element id="loginInput"in it.<br /> I thought the above would do the trick but no love. What am I doing wrong?<br /> Is there a better way to do this than to ping the server with a random get? I need a method that performes this check using ajax and any get or post done while logged out will get intercepted and the result will be the login-page instead of the intended page


$('#result').get(......); ???

<strong>UPDATE</strong> so the element #result would have what ever the #loginInput has

$('#result').load('login.php #loginInput');

Otherwise look for a json option because the way you are doing it, its kinda messy

Unless you are looking for this

$.get("nowhereGet", function(result){ if(result && $(result).find('#loginInput').length) { //HTML is in the response then we have been logged out and the user needs to go to window.location.href = "login"; } });


I found an <a href="https://stackoverflow.com/questions/6042843/struts-interceptor-giving-a-stream-result" rel="nofollow">other soloution</a> and with help from Steven Benitez I got it working. Follow the link for more information but in short I let my interceptor do the work instead. If a certain path/action is called the interceptor will return a text stream that I can read from my script.


  • Global results with Struts 2 and convention plugin
  • Use HTML5 input with Struts?
  • how access value of array list on Struts framework by properties file
  • How come struts property tag converts java.util.Date in m/d/yy format
  • Chrome breakpoint on radio doesn't fire
  • Tools for understanding HTML layout
  • Available space left on drive - WinAPI - Windows CE
  • Examples of how to a STS in .Net 4.5 using WCF
  • Zoom in and out of jPanel
  • Simulate click Geckofx vb,net
  • Firefox Extension - Monitor refresh and change of tab
  • Saving Changes After In-App Purchase Has Been Purchased
  • How do I pass the string value parameter of the selected list item from an auto-populated dropdown l
  • Jquery UI tool tip close icon
  • Django rest serializer Breaks when data exists
  • Meteor: Do Something On Email Verification Confirmation
  • Alert pop up with LWUIT
  • Recording logins for password protected directories
  • Disabling Alt-F4 on a Win Forms NotifyIcon
  • Is there any way to access browser form field suggestions from JavaScript?
  • HTML download movie download link
  • Where to put my custom functions in Wordpress?
  • htaccess rewriting URLs with multiple forward slashes
  • Display Images one by one with next and previous functionality
  • To display the title for the current loaction in map in iphone
  • Web-crawler for facebook in python
  • RestKit - RKRequestDelegate does not exist
  • How to get icons for entities from eclipse?
  • A cron job substitute?
  • AngularJs get employee from factory
  • WPF Applying a trigger on binding failure
  • Proper way to use connect-multiparty with express.js?
  • Load html files in TinyMce
  • Getting error when using KSoap library to consume .NET web services
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • JaxB to read class hierarchy
  • Django query for large number of relationships
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How can I use `wmic` in a Windows PE script?
  • How to push additional view controllers onto NavigationController but keep the TabBar?