Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>All you need to do is include a target="_blank" in the form on Site A, also the way that the request works on site B the siteSearchUrl input must be included</p> <pre><code>&lt;form id="apprenticeForm" action="http://www.apprenticesearch.com/Resources/SiteSearch" method="POST" target="_blank" onsubmit='submitSearch()'&gt; &lt;input type="text" name="searchText" id="searchText" value=""/&gt; &lt;input type="submit" value="Submit"/&gt; &lt;input id="siteSearchUrl" name="siteSearchUrl" type="hidden" value="http://yboss.yahooapis.com/ysearch/limitedweb?format=xml&amp;sites=www.apprenticesearch.com&amp;q="/&gt; &lt;/form&gt; </code></pre> <p>Like this <a href="http://jsfiddle.net/MVBLc/" rel="nofollow">http://jsfiddle.net/MVBLc/</a></p> <hr> <p>After playing around with the form submitting, but the q parameter not being read by Site B, I believe it's because the input had escaped <code>&amp;amp;</code> instead of '&amp;'. </p> <p>I've updated the HTML, and here's the javascript to update the field before submitting the form</p> <pre><code>function submitSearch() { q = document.getElementById("searchText").value; document.getElementById("siteSearchUrl").value = 'http://yboss.yahooapis.com/ysearch/limitedweb?format=xml&amp;sites=www.apprenticesearch.com&amp;q=' + q; return true; } </code></pre> <p><a href="http://jsfiddle.net/MVBLc/2/" rel="nofollow">Demo</a> </p> <p>The reason you need to use javascript for the additional input is the same reason why Site B uses javascript to populate siteSearchUrl in their <a href="http://www.apprenticesearch.com/Scripts/apprenticesearch.js" rel="nofollow">script</a> before it sends the request.</p> <p>Looking at how the server works: Site B sends that request to /Resources/SiteSearch where the <code>SiteSearch(String searchtext, String siteSearchUrl)</code> function gets called on their server. If you were to just go straight to that page with no post parameters you will find that a <code>System.ArgumentNullException Parameter name: uriString</code> is thrown for not having siteSearchUrl set from the server.</p> <p>If you want to analyze the parameters of siteSearchUrl:</p> <ul> <li>The URL <code>yboss.yahooapis.com</code> is for <a href="http://developer.yahoo.com/boss/search/boss_api_guide/index.html" rel="nofollow">Yahoo's BOSS</a> API servcie </li> <li>The <code>sites</code> parameter tells the API what site to search and display in the results</li> <li>and the <code>q</code> parameter is what query to search for</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload