javascript - Passing arguments to ajax within a generic function -


This is making me mad:

I can successfully pass arguments in this function, I can also pop the div from the warning ID, if I define values ​​in the function. function getStuff (req, elementid) {// var req = 'slider'; // var elementid = '#slider'; // var req = 'thumbnail'; // var elementid = '# thumbnails'; $ Ajax ({async: false, url: '/ update', contentType: 'text / html', data: {putski: req}, type: 'GET', datatype: "html", success: work (content) {$ (Elementid) .html (stuff); Warning (req + elementid)}, error: function (xhr, position, error) {Warning ("Sorry, there was a problem!"); ("Error:" + Error); Console .log ("position:" + status); console.dir (xhr);}, complete: function (xhr, position) {return false;}}); }; $ (Document) .ready (getStuff ('thumbnail', '# thumbnail')); // Warning thumbnail displays # thumbnails, but div is not populated

The following variation is populating and should exclude issues other than the characters described to me.

  function getStuff reiki, elimed) {var req = 'slider'; // To adopt these definitions and div dives element elemental = '#slider'; // var req = 'thumbnail'; // var elementid = '# thumbnails'; $ Ajax ({async: false, url: '/ update', contentType: 'text / html', data: {putski: req}, type: 'GET', datatype: "html", success: work (content) {$ (Elementid) .html (stuff); Warning (req + elementid)}, error: function (xhr, position, error) {Warning ("Sorry, there was a problem!"); ("Error:" + Error); Console .log ("position:" + status); console.dir (xhr);}, complete: function (xhr, position) {return false;}}); }; $ (Document) .ready (getStuff); // Population using the values ​​defined at the top.    

You're comparing apples to oranges

In the second version, you can try the following:

  var req = 'thumbnail'; Var Tacitid = '# Thumbnail';   

If this does not work, then you know that either the server code is not working correctly with the "thumbnail" parameter, or the element id "# thumbnail" is not defined is. I suspect that problem sets the parameters and sets them in function.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -