Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing url in async xhttp request not hitting server (although does it first time) - getting syntax error
    primarykey
    data
    text
    <p>In my html5 template (also using GAE and datastore/python), I'm making an async js call to server and coming back with some more categories FROM WHICH results/data choices are then given for the user to trigger another selection which shoots off the same async call method. It works the first time, but in the second, it comes back with a syntax error. The call doesn't even seem to make it to the method (no logs!), what gives??? The only difference between the 2 calls to the async js method is in the data passed through the url. There are 3 parameters passed with 1 parameter being used to form the url routing for the server. In both calls, an object key is part of the url. In the first one, the url is derived from the original template rendering through a jinja object {{item.key()}}. In the second one, the key is derived from the key which is stored as a value in the json dictionary passed back from the first one. Perhaps there is something going on here because it does not seem to even hit the server in the second?</p> <p>The first time the catkey is populated with jinja object key----: var html_output = ""; {% for item in cat_profession %}</p> <pre><code> var nameString = "{{item.name}}"; html_output += "&lt;a href=\"javascript:getNextLevel(\'{{item.key()}}\',\'{{item.name}}\')\"&gt;" + nameString + "&lt;/a&gt;&lt;br /&gt;"; {% endfor %} </code></pre> <p>which works BUT the second time, I'm using the results from the first one to generate categories to call json again to get more for (var key in cat_JSON) { html_output += "" + key + "<br />"; </p> <p>the cat_JSON[key] is a string --- there is something funky going on - but the console logs for the url seem to be ok and I don't see any evidence it is actually reaching server method. The JSON above has the name stored in the key, and the object key stored as the value. Here's the js function: </p> <pre><code> function getNextLevel(catkey,catname) { url = "/api/filter/" + catkey; subjectAPI.open("GET", url, true); console.log("url is ", url); subjectAPI.onload = function() { var cat_JSON = JSON.parse(this.responseText); var html_output = ""; for (var key in cat_JSON) { html_output += "&lt;a href=\"javascript:getNextLevel(\'" + cat_JSON[key] + "\',\'" + key + "\'," + ")\"&gt;" + key + "&lt;/a&gt;&lt;br /&gt;"; } $(#col).append(html_output); } subjectAPI.send(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload