406 happens when the server cannot respond with the accept-header specified in the request. so the response may not be acceptable to the server so Network error 406 coming.

Not acceptable will be triggered based on Accept, Accept-Charset, Accept-Language headers. So if your code is identical, it's likely that there's some setting related to content type.

Your backend service is saying that the response type it is returning is not provided in the Accept-Type HTTP header in your Client request.

SOLUTION:

$.ajax({
	   type: 'POST',
	   url: formUrl,
	   headers: { Accept : "text/plain; charset=utf-8","Content-Type": "text/plain; charset=utf-8",
       data: {},	                
	   success: function(return_val){
	   $('#id1').html(return_val);
	   },
	   error: function(xhr,textStatus,error){
	   alert(error+textStatus);
	 }); 

You have need to just add Header type in your AJAX code

headers: { Accept : "text/plain; charset=utf-8","Content-Type": "text/plain; charset=utf-8"}

Refrence:

1) http://en.wikipedia.org/wiki/List_of_HTTP_header_fields

2) http://en.wikipedia.org/wiki/HTTP_status_code

About The Massive Technolab

Avatar
Who We Are

Massive Technolab is a Leading IT services Company in India that expertise in web Development, Web Design and SEO at affordable rates.

Leave a Comment

comments powered by Disqus