Client JQuery invoke NetSuite Suitelet
Please indicate the source if you need to repost.
Client jQuery could initialize a cross-domain request. Certainly, jQuery could initialize a NetSuite request.
jQuery code (client):
function clickMe() {
try {
var myUrl = your_http_url;
$.ajax({
url: myUrl,
dataType: 'jsonp',
data: { "myName1": 2345 },
jsonp: 'callback',
jsonpCallback: "asyncButton",
success: function (result) {
for (var i in result) {
alert(i + " : " + result[i]); //Print response result
}
},
error: function (result1) { alert(2) },
timeout: 3000
});
}
catch (ex) {
alert(ex);
}
}
Client jQuery
Suitelet code (server):
function asyncButton(request, response) {
var x = request.getParameter('myName1');
var y = request.getParameter('myName2');
nlapiLogExecution('debug','test',x+', '+y);
response.write('asyncButton({"myName":"DanielCai"})');
}
NetSuite Suietlet
Note: Suitelet MUST check the 'Available without login' option.
Howerver, this kind of request doesn't have any credentials, which means it's an insecure request.
Restlet seems an optiop. I tried with Restlet, it didn't work out.
I guess the reason why it failed:
Cross-domain request MUST set 'Access-Control-Allow-Origin' in the server headers.
And Restlet doesn't allow coder to set the headers, so doesn't Suitelet.
I think the 'Available without login' option set the headers for us. :)
That's why Suitelet works for client jQuery
// Allow all the other parties to access.
header('Access-Control-Allow-Origin:*');
// Response type
header('Access-Control-Allow-Methods:POST');
// Response headers
header('Access-Control-Allow-Headers:x-requested-with,content-type');
PHP Server
Client JQuery invoke NetSuite Suitelet的更多相关文章
- .NET invoke NetSuite Restlet
Please indicate the source if you need to repost. Restlet allows programmers to use the http request ...
- 手机新闻网站,手持移动新闻,手机报client,jQuery Mobile手机新闻网站,手机新闻网站demo,新闻阅读器开发
我们坐在地铁.经常拿出新浪手机查看新闻.腾讯新闻,或者看新闻,等刷微信功能.你有没有想过如何实现这些目标. 移动互联网.更活泼. 由于HTML5未来,jQuery Moblie未来. 今天我用jqm的 ...
- 手机新闻网站,掌上移动新闻,手机报client,jQuery Mobile手机新闻网站,手机新闻网站demo,新闻阅读器开发
我们坐在地铁,经常来查看新浪手机新闻,腾讯新闻.或者刷微信看新闻更多功能.你有没有想过如何实现这些目标.移动互联网,更活泼. 因为HTML5到,jQuery Moblie到.今天我用jqm为了给你一个 ...
- JQuery invoke remote webservice
Sending the Access-Control-Allow-Origin header allows basic cross-origin access, but calling ASP.NET ...
- Writing Your Own jQuery Plugins
Setting Up <script src="js/jquery-1.9.1.min.js"></script> <script src=" ...
- org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Server returned error code = 404 for URI.. Check server logs for details
严重: Servlet.service() for servlet jsp threw exceptionorg.codehaus.xfire.XFireRuntimeException: Could ...
- Learning WCF Chapter1 Generating a Service and Client Proxy
In the previous lab,you created a service and client from scratch without leveraging the tools avail ...
- 【ASP.NET Web API教程】1.1 第一个ASP.NET Web API
Your First ASP.NET Web API (C#)第一个ASP.NET Web API(C#) By Mike Wasson|January 21, 2012作者:Mike Wasson ...
- MSCRM 通过Ajax调用WCF服务
Call WCF Service from Dynamics CRM using AJAX A couple of days back, I had one of my ex-colleagues c ...
随机推荐
- Web 前端开发精华文章集锦(jQuery、HTML5、CSS3)【系列十八】
<Web 前端开发精华文章推荐>2013年第六期(总第十八期)和大家见面了.梦想天空博客关注 前端开发 技术,分享各种增强网站用户体验的 jQuery 插件,展示前沿的 HTML5 和 C ...
- 【Android】Android ObjectAnimator动画初识、模仿
ObjectAnimator: ObjectAnimator的概念这里就不解释了,直接从代码中说明,以下是模仿Persicope的加载动画,简单的几行代码即可实现,当然我也是模仿的,更好的实现思路还请 ...
- 20个设计精致的用户界面 PSD 源文件免费下载
今天这篇文章收集了20个新鲜出炉的用户界面 PSD 源文件素材,你可以免费下载使用.这些免费素材不仅能帮助设计师们节省大量的时间,而且能有很好的效果.感谢那些很有才华的设计师分享它们的劳动成果,让更多 ...
- 实现winform DataGridView控件判断滚动条是否滚动到当前已加载的数据行底部
判断 DataGridView控件滚动条是否滚动到当前已加载的数据行底部,其实方法很简单,就是为DataGridView控件添加Scroll事件,然后写入以下代码就可以了,应用范围:可实现分部加载数据 ...
- 解决VS Code调试.NET Core应用遇到的坑
为什么会有”坑“ 博客园里有好多介绍怎么使用VS Code以及调试.NET Core的文章,但是都是基于直接构建Asp.Net Core Mvc单项目的,有什么区别呢! (1).我们这次遇到的坑是在多 ...
- ASP.NET MVC使用SSI来实现页面静态化
页面静态化分为两种:伪静态和真静态,这里主要介绍的是真静态. 进入正题之前先简单介绍一下SSI和shtml: 1).SSI是Server Side Include的简称(服务器端嵌入) 2).shtm ...
- ASP.NET MVC系列:开始
创建Asp.Net MVC项目 从visual studio主界面开始菜单中点击“新建项目”
- C#根据网址生成静态页面
HoverTree开源项目中HoverTreeWeb.HVTPanel的Index.aspx文件 是后台管理的首页. 包含生成留言板首页,以及显示用户名,退出等功能. 根据网址生成页面的方法: boo ...
- C#连接Excel示例代码和驱动
代码如下: string fileExt = Path.GetExtension(excelPath); string conn = ""; if (fileExt == &quo ...
- 检索 COM 类工厂中 CLSID 为 {28E68F9A-8D75-11D1-8DC3-3C302A000000} 的组件失败,原因是出现以下错误: 80040154 没有注册类 (异常来自 HRESULT:0x80040154 (REGDB_E_CLASSNOTREG))
Resvr32 .net中引用控件的名称 如果注册成功,问题不在出现 但是如果是在x64位的系统中,即使控件注册成功,错误依照提示,是因为大多数第三方写的COM控件,只支持32位的系统, 在VS中找到 ...