Extract part of HTML document in jQuery

You can use your standard selector syntax, and pass in the data as the context for the selector. The second parameter, data in this case, is our context. $.post(“getstuff.php”, function(data){ var mainDiv = $(“#mainDiv”, data); // finds <div id=’mainDiv’>…</div> }, “html”); This is equivalent to doing: $(data).find(“#mainDiv”); Depending on how you’re planning on using this, … Read more

ASP.NET MVC: How to display success confirmation message after server-side processing

I Would use TempData[“key”] This is like ViewData[“key”] however the data persists for the next HttpRequest and is disposed automatically by asp.net after this So you can do this. Controller Action [HttpPost] public ActionResult SomePostAction(SomeViewModel vm) { if(ModelState.IsValid) // Is User Input Valid? { try { CommitData(); TempData[“UserMessage”] = new MessageVM() { CssClassName = “alert-sucess”, … Read more

selectOneMenu ajax events

The PrimeFaces ajax events sometimes are very poorly documented, so in most cases you must go to the source code and check yourself. p:selectOneMenu supports change event: <p:selectOneMenu ..> <p:ajax event=”change” update=”msgtext” listener=”#{post.subjectSelectionChanged}” /> <!–…–> </p:selectOneMenu> which triggers listener with AjaxBehaviorEvent as argument in signature: public void subjectSelectionChanged(final AjaxBehaviorEvent event) {…}

Fetch post with body data not working params empty

Followed this topic on github: https://github.com/matthew-andrews/isomorphic-fetch/issues/34 The solution to my question is using the JSON.stringify function and set Content-Type header to application/json. Not pretty sure why the second attempt in my question didn’t work though. fetch(‘/api/v1/users’, { method: ‘post’, headers: {‘Content-Type’: ‘application/json’}, body: JSON.stringify({ “user”: { “email” : email, “password” : password }}), }) Official … Read more

Why is jqXHR.responseText returning a string instead of a JSON object?

I had the same problem. I returns a string because it formulated from an exception. E.g. I use a kernel listener with serialization to json on my Symfony2 project. Which is correct for proper REST headers. Anyway, just parse it; this works for me: $.ajaxSetup({ “error”: function(jqXHR, status, thrownError) { alert(‘error’); var responseText = jQuery.parseJSON(jqXHR.responseText); … Read more

How to properly render partial views, and load JavaScript files in AJAX using Express/Jade?

Great question. I don’t have a perfect option, but I’ll offer a variant of your solution #3 that I like. Same idea as solution #3 but move the jade template for the _full file into your code, since it is boilerplate and javascript can generate it when needed for a full page. disclaimer: untested, but … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)