JQuery load function returns 405 Method not allowed

I am dealing with a web application based on Google App Engine (Python). I am trying to update a div from a Polymer (HTML) element. The div I need to update is actually a container of elements. For this purpose, from a javascript snippet of an element, I am trying to get a div object via Jquery and call its load method like

 $('#myContainerId').load('/myQueryUrl?id=123123123');

      

The problem is I am getting 405 method not allowed

UPDATE

url is bound to Python webapp.RequestHandler through the application yaml file that implements the get method, makes a request to ndb, and renders the Jinja2 template.

UPDATE 2

The error in the console log while expanding says:

k.cors.a.crossDomain.send 
n.extend.ajax 
n.fn.load 
(anonymous function) 
j 
k.fireWith 
x 
(anonymous function)

      

It says there is a cross domain even though the domains are actually the same

+3


source to share


3 answers


Use $ .ajax () instead of $ .load () to explicitly control the request / response. This might do the trick (you may need to tweak the options):



$('#myContainerId').ajax({
  crossDomain: FALSE,
  type: "POST", // || GET || PUT || DELETE
  url: '/myQueryUrl?id=123123123'
});

      

+3


source


You can also try a more explicit method related to using the .POST data. As long as you have a newer version of JQuery that you are using. The .POST [ $.post("fileHandler.php", {"..."), function(data) {...});

] method might be more appropriate for this situation.

Final result:

$.post("myHandler.php", {urlToReceive: jsUrlStoredVariable}, function(data) {
    //What to do when your data is returned...
});

      



However, as far as your current problem remains ...

Since there were no error reports, JSFiddles or code samples were indeed provided

+1


source


 $('#myContainerId').load('myQueryUrl?id=123123123');

      

+1


source







All Articles