Blog

Latest Updates. News. Insights. Ideas.

June 2007 - Sahi Pro

Ajax and Sahi

Posted by | features, technical | One Comment

Problem

In Sahi, some javascript is added to all pages. In an ajax call, the response should be xml. But sahi may taint the xml with its javascript and hence ajax calls may stop working. Sahi looks at the content type of a file before it injects its js, but most of the time the ajax responses also have the content type as text/html

Solution

Sahi can be asked to not inject js into requests whose urls follow specific patterns.
Say urls which have say “/ajax/” in them can be excluded from injection.

What you need to do is add the regular expression pattern of the ajaxy urls to config/exclude_inject.txt
so if your url is something like
http://www.example.com/ajax/list.html” use
“.*/ajax/.*” (without quotes) to match all urls with /ajax/ in them and exclude them from js injection.

Use fully-loaded Sahi Pro FREE for a month. Download Now Request a Demo