Question

I call an ASHX handler through jquery using dataType: 'html', type: 'GET' and few parameters.

There are some results which are retrieved from ASHX handler. and using content type 'html', the results (which are mixture of html tags and javascript) are appending (using jquery appendTo) to a div dvProducts. The html and javascript populated from ASHX handler are working fine in each browser. Although while viewing div dvProducts in view source, it is empty. The div can be inspected in chrome or firefox with proper tags and hierarchy underneath.

Basically, it is search for products by name and the handler queries and set the layout to display.

The issue only came when the result div seems empty when view source. This is needed for google caching and indexing the page.

Please assist in this scenario and suggest if there is any better approach.

Was it helpful?

Solution

You'll need to populate your div server side instead of only relying on JavaScript. Refactor your code so you can insert the html via your asp.net template engine. If you're using WebForms, put that code in a User Control and render it from your ashx so it can be retrieved by JavaScript (check out RenderControl). Then go to the User Control/Page that contains the div and insert your new User Control there. Now you can't append the html you retrieve from your ashx - you have to replace the innerHTML of your div with the html from your ashx.

OTHER TIPS

"The html and javascript populated from ashx handler are working fine in each browser. Although while viewing div 'dvProducts' in view source, it is empty."

If you are sure that your handler is working fine, then please have a look in browser console after the request to handler from jquery or use debug tool that are provided with the browser. Because if your handler is working fine then just appending the handler response to the div shouldn't be an issue.

If you can provide some of your code then it will be easy for the community to guide you in the proper direction

Basically the Ajax generated content is dynamic and can not be index or crawled, have a look in this https://developers.google.com/webmasters/ajax-crawling/

They have some methods/concepts that may help you

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top