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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:10:22+00:00 2026-05-26T14:10:22+00:00

I am puzzled, I have a call with jQuery using .load to fill a

  • 0

I am puzzled, I have a call with jQuery using .load to fill a DIV with content composed of transformed XML into HTML, but whenever I call load (or $.get or $.ajax for that matter) I get a “400 Bad Request – The request sent by the client was syntactically incorrect” message.

The parameters are all there and even when I set up a test call for a page with no parameters I get the same message. All this is being done via Spring (v3) with an annotated controller. What’s confusing is that I already have a portion of this working with calls to a web service that return a JSON object to fill a SELECT and that works fine.

How do I fill the DIV with HTML?

Javascript jQuery call:

        function doSearch()
        {
           var sUrl = "query.html";
           var sSecurityToken = '?st=' + $('#ihSecurityToken').val();

           var sProjects = '';
           $("#sltProjects option:selected").each(function () 
              {
                 sProjects += $(this).val() + ';';
              });
           sProjects = '&pn=' + escape(sProjects);

           var sDatabases = '';
           $("#sltDatabases option:selected").each(function () 
              {
                 sDatabases += $(this).val() + ';';
              });
           sDatabases = '&db=' + escape(sDatabases);

           var sQueryText = '&qt=' + escape($('#taSearchText').val());

           sSort = '&sr=' + $('#sltSort').val();
           sResultsPerPage = '&rp=' + $('#sltResultsPerPage').val();
           sRelevance = '&rl=' + $('#sltRelevance').val();

           var sFilters = '&ft=';
           var sTemp = '';
           $("[id^=fld]").each( function() 
              {
                 sName = $(this).attr('alt');
                 sValue = escape($(this).val());
                 sTemp += escape((sName + '=' + sValue + ';'));
              });

           if (sTemp.length)
           {
              sFilters += sTemp;
           }
           else
           {
              sFilters = '';
           }

           var sStartingPage = "&sp=1";


           sFinal = sUrl + sSecurityToken + sProjects + sDatabases + sQueryText + sSort + sResultsPerPage + sRelevance + sFilters + sStartingPage;
           $('#resultsBlock').load(sFinal);
}

Controller code:
package enterprisesearch.web;

import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.xml.parsers.ParserConfigurationException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.stereotype.Controller;
import org.springframework.util.ClassUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.xml.sax.SAXException;

import enterprisesearch.domain.DatabaseFilter;
import enterprisesearch.domain.UserDatabaseProject;
import enterprisesearch.domain.service.DouglasService;
/**
 * @author bob
 *
 */
@Controller
public class SearchController
{
   protected final Log logger = LogFactory.getLog(getClass());

   private DouglasService dgWebService = new DouglasService("http://localhost:8080/Douglas/services/Douglas");

   @RequestMapping("/search.html")
   @ModelAttribute("message")
   public String getMessage()
   {
      return "Results go here...";
   }

   @ModelAttribute("username")
   public String getUsername(@RequestParam(value="username", required=true) String psUsername)
   {
      return psUsername; 
   }

   @ModelAttribute("securitytoken")
   public String getSecurityToken(@RequestParam(value="username", required=true) String psUsername)
   {
      String sReturn = "";
      Map<String, String> mpResult = this.dgWebService.getSecurityToken(psUsername);

      if (mpResult.containsValue("SUCCESS"))
      {
         sReturn = mpResult.get("securityinfo");
      }
      else
      {
         sReturn = mpResult.get("errorid");
      }

      return sReturn;
   }

   @ModelAttribute("userprojects")
   public Collection<UserDatabaseProject> getUserProjects(@RequestParam(value="username", required=true) String psUsername) throws ParserConfigurationException, SAXException, IOException
   {
      String sUsername = "";
      if (psUsername == null || psUsername.isEmpty())
      {
         sUsername = "lymana";
      }
      else
      {
         sUsername = psUsername;
      }
      return this.dgWebService.getUserDatabaseProjects(sUsername);
   }

   @RequestMapping("/databases.html")
   public @ResponseBody Map<String, String> getUserDatabases(@RequestParam(value="username", required=true) String psUsername, @RequestParam(value="projectname", required=true) String psProjectName) throws ParserConfigurationException, SAXException, IOException
   {
      Map<String, String> mpDatabases = new HashMap<String, String>();

      Collection<UserDatabaseProject> udpProjects = this.dgWebService.getUserDatabaseProjects(psUsername);
      if (udpProjects.size() > 0)
      {
         for (UserDatabaseProject udpProject : udpProjects)
         {
            if (psProjectName.indexOf(udpProject.get_msProjectName()) != -1)
            {
               mpDatabases.put(udpProject.get_msDatabaseName(), udpProject.get_msDatabaseDescription());
            }
         }
      }
      else
      {
         mpDatabases.put("","No databases were found for the selected project");
      }

      return mpDatabases;
   }

   @RequestMapping("/filters.html")
   public @ResponseBody Map<String, String> getCommonDBFilters(@RequestParam(value="databases", required=true) String psDatabaseNames) throws ParserConfigurationException, SAXException, IOException
   {
      Map<String, String> mpDatabases = new HashMap<String, String>();

      Collection<DatabaseFilter> dfFilters = this.dgWebService.getCommonDBFilters(psDatabaseNames);
      if (dfFilters.size() > 0)
      {
         for (DatabaseFilter dfFilter : dfFilters)
         {
            if (psDatabaseNames.indexOf(dfFilter.get_msDatabaseName()) != -1)
            {
               mpDatabases.put(dfFilter.get_msFilterName(), dfFilter.get_msFilterName());
            }
         }
      }
      else
      {
         mpDatabases.put("","No filters were found for the selected database(s)");
      }

      return mpDatabases;
   }


   @RequestMapping("/test.html")
   public ModelAndView execTest()
   {
      //Map<String, String> mpDatabases = new HashMap<String, String>();
      ModelAndView mavReturn = new ModelAndView("test.jsp");
      //mpDatabases.put("test","<b>No filters were found for the selected database(s)</b>");

      return mavReturn;
   }

   //@ModelAttribute("searchResults")
/*   @RequestMapping(value = "/query.html", method = RequestMethod.GET)
   public ModelAndView doSearch(@RequestParam(value="st", required=true) String psSecurityToken,
         @RequestParam(value="pn", required=true) String psProjects,
         @RequestParam(value="db", required=true) String psDatabases,
         @RequestParam(value="qt", required=true) String psQueryText,
         @RequestParam(value="sr", required=true) String psSort,
         @RequestParam(value="rp", required=true) String psResultsPerPage,
         @RequestParam(value="rl", required=true) String psRelevance,
         @RequestParam(value="sp", required=true) String psStartingPage,
         @RequestParam(value="ft", required=false) String psFilters)
   {
      ModelAndView mavReturn = new ModelAndView("query.jsp");
      String sTemp = "";
      String sOptions = "";
      String sStartingPage = "1";
      if (!psStartingPage.isEmpty())
      {
         sStartingPage = psStartingPage;
      }

      String sSort = "Sort=" + psSort;
      String sResultsPerPage = "ResultsStart=" + sStartingPage + ";ResultsEnd=" + psResultsPerPage;
      String sDatabases = "Repositories=" + psDatabases.replace(';', ',');
      String sRelevance = "RelevanceMin=" + psRelevance;
      String sDefaults = "Print=All;SummaryType=Context;Highlighting=Terms+SummaryTerms;";
      sOptions = sSort + ";" + sResultsPerPage + ";" + sDatabases + ";" + sRelevance + ";" + sDefaults;

      //sReturn = this.dgWebService.executeTextQuery(psSecurityToken, psProjects, psDatabases, psQueryText, sOptions, psFilters);
      sTemp = "<b>This is a test</b>";
      mavReturn.addObject("searchResults", sTemp);
      return mavReturn;
   }*/

   /*@RequestMapping(value = "/test.html", method = RequestMethod.GET)
   public ModelAndView doTest(@RequestParam(value="st", required=true) String psSecurityToken)
   {
      String sTemp = "";
      ModelAndView mavReturn = new ModelAndView("test.jsp");

      //sReturn = this.dgWebService.executeTextQuery(psSecurityToken, psProjects, psDatabases, psQueryText, sOptions, psFilters);
      sTemp = "<b>This is a test</b>";
      mavReturn.addObject("searchResults", sTemp);
      return mavReturn;
   }*/


}

URL:

http://localhost:8085/EnterpriseSearch/query.html?st=kjahsdf9845hasfha9348uwhefas&pn=ECC%3B&db=dbECC%3B&qt=money&sr=relevance&rp=10&rl=90&sp=1&ft=false

Firebug info:

Response Headersview source
Server  Apache-Coyote/1.1
Content-Type    text/html;charset=utf-8
Content-Length  971
Date    Thu, 03 Nov 2011 20:06:56 GMT
Connection  close
Request Headersview source
Host    localhost:8085
User-Agent  Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.23) Gecko/20110920             Firefox/3.6.23
Accept  text/html, */*; q=0.01
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive  115
Connection  keep-alive
X-Requested-With    XMLHttpRequest
Referer http://localhost:8085/EnterpriseSearch/search.html?username=lymana
Cookie  JSESSIONID=CC30B029E8C9215489D4F938A6C1BB9D

Any ideas? What am I missing?

Updated to include the complete Controller code.

  • 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-26T14:10:23+00:00Added an answer on May 26, 2026 at 2:10 pm

    I copied and pasted your Java code into my Spring 3.0 testing application, and hit that URL manually. If you hit that URL directly, do you get the same 400?

    There are a few simple problems I could see happening, but you’ve most likely already ruled them out.. I just don’t have enough info reading your message to know!

    1. Do you have a view that matches the string that you’re returning from the RequestMapped function?
    2. Is it even calling that doSearch function(), if you add a trace message to it?
    3. Is there anything at all in your error logs?
    4. What does your access log say?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm trying to load a javascript remotely using jquery's $.getScript, but I'm puzzled
I'm a little puzzled with QueryStrings and ActionResult I have a URL coming in
This one has me puzzled. It seemed like an easy task, but the solution
In Javascript I'm trying to pass a class member to a jQuery function, but
I'm puzzled... I have this function colorWithHexString... when I include it in the viewcontroller
I have searched here and on Google, but as an inexperienced Javascript hack I'm
I'm puzzled by the return values on Java's Lists. I would have expected operations
I'm still puzzled on the usage of a RequestDispatcher. If i have a javascript
I've run into this behavior after using JS for a few months. I'm very
I have a one-line script passed into the foreach function in a Makefile, as

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.