JQuery getJSON – ajax parseerror

The JSON string you have is an array with 1 object inside of it, so to access the object you have to access the array first. With a json.php that looks like this: [ { “iId”: “1”, “heading”: “Management Services”, “body”: “<h1>Program Overview</h1><h1>January 29, 2009</h1>” } ] I just tried this $.getJSON(“json.php”, function(json) { alert(json[0].body); … Read more

How could I change window’s location without reloading and # hack?

Facebook is using the history api in HTML5. From this blog post you can see how this works. Basically they are making calls like the one below to change the url without reloading the page. window.history.pushState(“object or string”, “Title”, “/new-url”); Here is the HTML5 working draft spec about it: http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#the-location-interface Sadly, IE9 does not support … Read more

How do I install and use the ASP.NET AJAX Control Toolkit in my .NET 3.5 web applications?

Install the ASP.NET AJAX Control Toolkit Download the ZIP file AjaxControlToolkit-Framework3.5SP1-DllOnly.zip from the ASP.NET AJAX Control Toolkit Releases page of the CodePlex web site. Copy the contents of this zip file directly into the bin directory of your web site. Update web.config Put this in your web.config under the <controls> section: <?xml version=”1.0″?> <configuration> … … Read more

Post JavaScript array with AJAX to asp.net MVC controller

You could define a view model: public class AddUserViewModel { public int ProjectId { get; set; } public int[] userAccountIds { get; set; } } then adapt your controller action to take this view model as parameter: [HttpPost] public ActionResult AddUsers(AddUserViewModel model) { … } and finally invoke it: function sendForm(projectId, target) { $.ajax({ url: … Read more

GET vs POST in AJAX?

You should use the proper HTTP verb according to what you require from your web service. When dealing with a Collection URI like: http://example.com/resources/ GET: List the members of the collection, complete with their member URIs for further navigation. For example, list all the cars for sale. PUT: Meaning defined as “replace the entire collection … Read more

Parsing returned HTML from jQuery AJAX request

Your code works fine. You just aren’t using jsFiddle’s API correctly. Check the docs for /echo/html/ (http://doc.jsfiddle.net/use/echo.html#html): URL: /echo/html/ Data has to be provided via POST So, you need to update your AJAX call to use POST. Also the trailing slash is needed. $(function () { $.ajax({ url: “/echo/html/”, type: “post”, dataType: “html”, success: function … Read more

How to convert a byte array into an image?

I realize this is an old thread, but I managed to do this through an AJAX call on a web service and thought I’d share… I have an image in my page already: <img id=”ItemPreview” src=”” /> AJAX: $.ajax({ type: ‘POST’, contentType: ‘application/json; charset=utf-8’, dataType: ‘json’, timeout: 10000, url: ‘Common.asmx/GetItemPreview’, data: ‘{“id”:”‘ + document.getElementById(“AwardDropDown”).value + … Read more