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 ...
随机推荐
- PHP实现简易blog
最近,有时间看了点PHP的代码.参考PHP100教程做了简单的blog,网易云课堂2012年的教程,需要的可以找一下,这里面简单的记录一下. 首先是集成环境,这里选用的WAMP:http://www. ...
- 15个来自 CodePen 的酷炫 CSS 动画效果【下篇】
CodePen 是一个在线的前端代码编辑和展示网站,能够编写代码并即时预览效果.你在上面可以在线分享自己的 Web 作品,也可以欣赏到世界各地的优秀开发者在网页中实现的各种令人惊奇的效果. 今天这篇文 ...
- 让你心动的 HTML5 & CSS3 效果【附源码下载】
这里集合的这组 HTML5 & CSS3 效果,有的是网站开发中常用的.实用的功能,有的是先进的 Web 技术的应用演示.不管哪一种,这些案例中的技术都值得我们去探究和学习. 超炫的 HTML ...
- Android 触摸事件处理机制
Android 触摸事件的处理主要涉及到几个方法:onInterceptTouchEvent(), dipatchTouchEvent(), onTouchEvent(), onTouch(). on ...
- 【Java基础】方法
Num1:检查参数的有效性 绝大多数的方法和构造器对于传递给它们的参数值都会有某些限制.比如:索引值必须是非负数,对象引用不能为null等等.这些都很常见,你应该在文档中清楚地指明所有这些限制,并在方 ...
- Android自动化测试之Monkeyrunner学习笔记(一)
Android自动化测试之Monkeyrunner学习笔记(一) 因项目需要,开始研究Android自动化测试方法,对其中的一些工具.方法和框架做了一些简单的整理,其中包括Monkey.Monkeyr ...
- Windows Azure Active Directory (3) China Azure AD增加新用户
<Windows Azure Platform 系列文章目录> 本文介绍的是国内由世纪互联运维的China Azure. 本文是对笔者之前的文档:Windows Azure Active ...
- Visual Studio 2012 Update 4 RC 启动调试失败解决方案
以下解决办法适用于任何Visual Studio开发环境,及Windows NT 6.1以上系统. 系统:Windows 8.1 Enterprise x64 RTM 开发环境:Visual Stud ...
- Emit学习(2) - IL - 常用指令介绍
学习Emit必不可少的, 会使用到IL中间代码. 初见IL代码, 让我有一种汇编的感觉, 让我想起了, 大学时, 学习8051的汇编语言. 多的就不扯了, 直接进入正题, OpCodes指令集是不是有 ...
- Visual Studio 技能GET
常用快捷键 自动生成头部注释 代码片段 NuGet Team Foundation 常用的VS快捷键 查看与设置快捷键 一般在菜单里面我们直接就可以看到一些功能的快捷键.另外,可以依次通过 菜单栏-工 ...